Fork me on GitHub
#graphql
<
2018-05-17
>
devth17:05:51

the docs at http://lacinia.readthedocs.io/en/latest/resolve/async.html mention: > different fields within the same query may operate on different databases or other backend data sources this is my case, but the example only shows async resolving a single entity in the resolve-user function. what if the fields on a single entity come from different sources? not clear how a single promise could help aggregate those fields within a single resolver.

devth17:05:49

maybe this is not the right tool or maybe i structured my schema incorrectly. example object:

:stats {:fields
         {:uptime {:type String}
          :adapters {:type Int}
          :users {:type Int}
          :commands_today {:type Int}
          :commands_all_time {:type Int}}}
i want to resolve all of those fields in parallel because they're all aggregations / separate db queries. i thought Asynchronous Field Resolvers would be exactly what I needed but maybe not.

devth17:05:51

i suppose i can use my own async means of aggregating that data. just curious if lacinia supported something like that.

hlship17:05:41

Yes, I think you would run your own processes asynchronously, and when all are available, you could deliver! the results. You can use the preview API to see just what will be selected.

hlship17:05:38

Or, you could have a resolver for each of those fields (:uptime, :adapters, etc.) and each could return an async ResolverResultPromise. Lacinia will invoke each of your resolvers, then asynchronously process each of them as a value is deliver!-ed.

hlship17:05:06

The resolver for the :stats field can provide, in its resolved value, some form of id that is used by the nested field resolvers. Alternately, it can put a value into the field resolver context using the with-context wrapper.

devth17:05:14

thanks! i'll explore these options

hlship18:05:09

So I've build a fix for https://github.com/walmartlabs/lacinia-pedestal/issues/50 but then I re-read the spec and I'm still not convinced that the current behavior is incorrect. Could someone knowledgable about Apollo client please weigh in?

hlship22:05:33

I just posted a PR that lets you tune the hidden channels used to implement subscriptions. https://github.com/walmartlabs/lacinia-pedestal/pull/68

hlship22:05:47

I forget who it was that suggested this option.