Fork me on GitHub
#graphql
<
2018-08-21
>
tbaldridge19:08:04

Does lacinia support parameterized queries? And if so, is it possible to hook into the library in such a way that I can cache backend queries?

tbaldridge19:08:21

What I want to do is reuse queries when only the parameters change from one GraphQL query to the next.

hiredman20:08:47

I find that question kind of confusing, maybe I am having a hard time determining what query is referring to in context (graphql query, backend query?)

hiredman20:08:58

a particular resolver will be called, and it can be a stateful thing that keeps any kind of of cache you want

tbaldridge20:08:52

@hiredman GraphQL supports "stored procedures" of a sort: https://graphql.org/learn/queries/#variables

tbaldridge20:08:44

The Java GraphQL API uses this to only perform parsing/validation when the query string is un-cached.

hiredman20:08:45

those don't effect how the query is run

hiredman20:08:28

I think you could do that with lacinia

tbaldridge20:08:46

Agreed, but in my case they do, I want to push that down into my query logic. There's some optimizations and complex logic happening in my data fetchers and I'd love to be able to re-use those

hiredman20:08:59

I think you could do that, because it is possible to parse a query separately from executing it (so you could cache the parse step) and you could push that information down in to the resolvers using the context

hiredman20:08:38

but it seems like it would be better to have the resolvers cache whatever based on the args?

tbaldridge20:08:15

That's a good point, I'll think it over a bit