Fork me on GitHub
#graphql
<
2022-01-03
>
Daniel Craig19:01:02

What's the correct way to provide variables when making a query to lacinia using re-graph? This is the example given in the readme but I can't seem to figure out how the 'id' field is populated.

;; perform a query, with the response sent to the callback event provided
(re-frame/dispatch [::re-graph/query
                    :my-query-id         ;; unique id for this query
                    "{ things { id } }"  ;; your graphql query
                    {:some "variable"}   ;; arguments map
                    [::on-thing]])       ;; callback event when response is recieved
https://github.com/oliyh/re-graph

Daniel Craig19:01:14

@U26FJ5FDM I see

(re-frame/reg-event-fx
  ::get-account
  (fn [cofx [_ username password]]
    {:db       (assoc-in (:db cofx) [:login-status :username] username)
     :dispatch [::re-graph/mutate
                "($username: String! $password: String!){get_account(username: $username password: $password) {reason iban token}}"
                {:username username :password password}
                [::on-get-account]]}))
at https://github.com/gklijs/bkes-demo/blob/b57d3d6c9f73671e61a8fbabaede1abc12667ab7/frontend/src/cljs/nl/openweb/bank/events.cljs#L112 I'll try to use this example to figure it out

Daniel Craig19:01:00

I got it figured out! Sorry to pester!

1
👍 1