Fork me on GitHub
#graphql
<
2019-07-17
>
timgilbert18:07:21

Say, in lacinia is it possible to attach metadata to the response? My use case is I'm trying to instrument some code and determine, eg, which project an event took place in, but I might not actually determine that information until I'm fairly deep in the resolver stack. What I'd like is a mechanism where an arbitrary resolver could figure out "aha, this is project X and user Y", and then when I get the results of (lacinia/execute) I'd like to pull that data back out, but I don't want it to be returned to the client.

timgilbert18:07:12

Basically I'm wondering if I can get the context object back from execute.

hlship20:07:49

Lacinia's model isn't super sophisticated; we recurse from the roots to the leaves, then select on the way back up, building the final GraphQL result map leaf-to-root. So that becomes a challenge to do the kind of thing you mention w/o resorting to an Atom. The internal implementation makes use of some Atoms to store errors and a few other things (technically not necessary, but was a big performance operation and kept hidden). This feels like something with-extensions would help with ... even if you then had a Pedestal interceptor removing the extensions before sending response to client. http://walmartlabs.github.io/apidocs/lacinia/com.walmartlabs.lacinia.resolve.html#var-with-extensions

timgilbert23:07:34

Thanks @hlship, will look into that