This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-03-05
Channels
- # announcements (8)
- # asami (70)
- # babashka (28)
- # beginners (163)
- # calva (7)
- # cider (15)
- # clj-kondo (47)
- # cljs-dev (45)
- # clojars (2)
- # clojure (56)
- # clojure-europe (24)
- # clojure-italy (1)
- # clojure-losangeles (2)
- # clojure-nl (4)
- # clojure-spec (2)
- # clojure-uk (53)
- # clojurescript (46)
- # data-oriented-programming (15)
- # data-science (10)
- # datahike (2)
- # defnpodcast (1)
- # depstar (27)
- # emacs (35)
- # figwheel-main (28)
- # fulcro (38)
- # girouette (1)
- # graphql (16)
- # jobs-discuss (3)
- # kaocha (9)
- # keechma (2)
- # leiningen (6)
- # lsp (87)
- # malli (19)
- # membrane (16)
- # pathom (4)
- # re-frame (11)
- # shadow-cljs (25)
- # spacemacs (2)
- # testing (12)
- # tools-deps (14)
- # tree-sitter (4)
- # xtdb (20)
Has anyone encountered an issue with Lacinia where if you have arguments to a field, the resolver is asynchronous, and the parent resolver is asynchronous, the parent and child execute in parallel? I have a child resolver that depends on the parent to pass down context values, but when the child is asynchronous and has arguments the execution order is not what I expect it to be.
I’m thinking maybe this is part of the GraphQL spec, but I haven’t been able to track it down.
Normally it waits for the parent to resolve before resolving the child even when both are async, but adding arguments to the field resolver causes that to change.
gotcha makes sense, thanks
This is the part of the Lacinia docs I read that I thought suggested it would happen in the order I stated above
https://lacinia.readthedocs.io/en/latest/resolve/selections.html
In execution order, resolution occurs top to bottom, so the hero selection occurs first, then (potentially in parallel) friends, home_planet, and (hero) name. These last two are leaf nodes, because they are scalar values. The list of characters (from the friends field) then has its name field selected. The result map then constructs from bottom to top.
is there a key in the context (or maybe something in the selection
protocols) that allows a resolver to find out what query/mutation/subscription it was invoked from?
preferably something that is part of the public api.
Generally, if children need information from a higher level, a parent resolver puts data into the context that is passed down to children.
yeah, that will work. Can just leave bread crumbs that way.
Also, if it's a parent resolver and immediate child resolver, then just stuff the extra data into the resolved value (probably using namespaced keys to avoid any conflicts). It's only when operating at a further remove that the context approach makes sense.
An example: we collect a search term from a field argument in our root query operation; that goes into the context, because we need it a couple of layers deeper when we're filtering items by the search key. There's (in our app) layers of orders, and item groups, between the query operation resolver, and the matching items resolver that actually needs the search key.
excellent suggestion.