I am researching how to use graphql in clojure and it all seems to make 
sense, and I can follow the Demo Project, except for the resolver-fn

In https://github.com/tendant/graphql-clj the resolver function is defined 
to be

(defn resolver-fn [type-name field-name]
      (cond
        (and (= "QueryRoot" type-name) (= "user" field-name)) (fn [context 
parent args]
                                                                {:name 
"test user name"
                                                                 :age 30})))

And in the demo, https://github.com/tendant/graphql-clj-starter, the 
resolver function is

(defn starter-resolver-fn [type-name field-name]
  (match/match
   [type-name field-name]
   ["Query" "hero"] (fn [context parent args]
                      (get-hero (:episode args)))
   ["Query" "human"] (fn [context parent args]
                       (get-human (str (get args "id"))))
   ["Query" "droid"] (fn [context parent args]
                       (get-droid (str (get args "id"))))
   ["Query" "objectList"] (fn [context parent args]
                            (repeat 3 {:id (java.util.UUID/randomUUID)}))
   ;; Hacky!!! Should use resolver for interface
   ["Human" "friends"] (fn [context parent args]
                         (get-friends parent))
   ["Droid" "friends"] (fn [context parent args]
                         (get-friends parent))
   ["Character" "friends"] (fn [context parent args]
                             (get-friends parent))
   ["Mutation" "createHuman"] (fn [context parent args]
                                (create-human args))
   :else nil))

I am confused about what arguments the resolver-fn should take.

I see that it returns another function but where do the context, parent and 
args come from for this function.

Any help would be much appreciated

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to