Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Caching directives from apollo in schema #439

Closed
akoufa opened this issue Oct 4, 2019 · 5 comments
Closed

Caching directives from apollo in schema #439

akoufa opened this issue Oct 4, 2019 · 5 comments

Comments

@akoufa
Copy link

akoufa commented Oct 4, 2019

Hey I am trying to introduce @cacheControl from https://www.apollographql.com/docs/apollo-server/performance/caching/ to provide HTTP caching headers in the response and unfortunately I cannot find a way to add them via nexus-prisma. It is only possible when using GraphQL Schema definition through SDL but I would like to define it via code-first GraphQL. Is it possible to add this functionality to nexus-prisma ?

@iherger
Copy link

iherger commented Oct 5, 2019

You can add cache hints dynamically to your resolvers (not only statically in your schema), see https://www.apollographql.com/docs/apollo-server/performance/caching/#adding-cache-hints-dynamically-in-your-resolvers

@akoufa
Copy link
Author

akoufa commented Oct 5, 2019

Hello @iherger. I know that I can already add cache hints dynamically in the resolvers but I don't want to add in every resolver method, extra static caching code when I could do that via a directive. That's why I opened this issue to request the possibility to add custom directives using nexus-prisma.

@iherger
Copy link

iherger commented Oct 5, 2019

@akoufatzis, sorry, then I misunderstood your question. Your question seems to have been discussed before in prisma-labs/graphql-framework-experiment#53 and it seems to be in the pipeline.

@akoufa
Copy link
Author

akoufa commented Oct 5, 2019

Ok then I will close this issue and follow the one you mentioned. Thank you.

@akoufa akoufa closed this as completed Oct 5, 2019
@alexandrduduka
Copy link

Hey, we are hitting the same problem, trying to define cacheControls on the specific queries, but have no luck.

When using the constructions like t.model.order on some of the object types, there is no way to specify maxAge for the nested fields. Let's say we have a construction like order -> customer -> addresses -> id, in this case even if we specify cache hint on the order subfields will have defaultMaxAge=0, and the request never gets cached. We have been trying different workarounds but did not manage to get it running.

Is there some known way to deal with this issue? I can't believe the whole code-first community runs without using caching :)

@akoufa, could you share your findings?
@iherger, I see that the discussion you mentioned leads to this hanging issue apollographql/apollo-server#3589, is there some known way to provide cache hints for nested fields without rewriting everything to custom types and resolves and utilizing all the Prisma goodies?

Thanks a lot in advance!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants