Fork me on GitHub
#pathom
<
2022-07-31
>
roklenarcic21:07:47

How do I get to params in foreign AST? So I have a dynamic resolver, which trigger with query [{([:my/id 1] {:param/test "test"}) [:my/name]}] so query with an ident with a param on it. The foreign AST my dynamic resolver gets is {:type :root :children […. node for :my/name]} . I couldn’t find :param/test anywhere in the whole environment in my dynamic resolver resolve function

souenzzo09:08:53

you are probably asking how to access "parent" params in :my/name resolver. Well, pathom do not "support" that, but as #fulcro add the parameters in this place by default, I used to use a code like this in one of my projects:

(defn eql-api
  [req]
  (let [query (... req)
        ast (eql/query->ast query)
        root-params (-> ast
                      :children 
                      (->> (keep :params)
                        (apply merge)))
        result (parser (assoc env :root-params root-params)
                 query)]
    {:status 200
     :body   result ...}))