Skip to content
This repository has been archived by the owner on Sep 7, 2020. It is now read-only.

Allow specifying cacheControl attributes on Types and Fields #339

Open
1 task
marktani opened this issue Jan 23, 2018 · 3 comments
Open
1 task

Allow specifying cacheControl attributes on Types and Fields #339

marktani opened this issue Jan 23, 2018 · 3 comments

Comments

@marktani
Copy link
Contributor

Issue by kbrandwijk
Wednesday Oct 25, 2017 at 17:56 GMT
Originally opened as https://github.com/graphcool/prisma/issues/1032


What feature are you missing?
I am trying to configure caching on my Apollo API Gateway. For this, I need to add @cacheControl directives to my Types and fields. When I try to do that, the server doesn't throw any error, but the directives are silently removed. Unfortunately, mergeSchemas does not allow redefining fields, so it would be helpful if I could add them on the Graphcool side.

Also, the top-level queries that are generated are not accessible from the schema. It would be nice to be able to define cacheControl attributes for the generated query fields as well somehow.

Apollo Cache Control is an open standard, that will not only be implemented by Apollo Server, but also Sangria, etc. (according to their docs), so this is not a 'vendor-specific' thing.

How could this feature look like in detail? Tradeoffs?

  • Do not remove additional directives.
  • Proposal for generated query fields is to take the cacheControl attribute off the Type, so if I define:
type Post @model @cacheControl(maxAge: 30) {
 ...
}

Then the generated queries would also get that setting:

type Query {
   allPosts(...) @cacheControl(maxAge: 30)
   Post (...) @cacheControl(maxAge: 30)
}

Depends on:

  • Expose user-defined directives in API schema #1228
@marktani
Copy link
Contributor Author

Comment by marktani
Saturday Oct 28, 2017 at 06:56 GMT


Can you provide links to more resources about @cacheControl? :)

@marktani
Copy link
Contributor Author

Comment by kbrandwijk
Saturday Oct 28, 2017 at 13:23 GMT


I have a working example here: https://github.com/kbrandwijk/graphcool-gateway-apollo-engine-demo#caching-example. The reason behind this issue is that adding directives to an existing field in a Gateway is difficult (see: ardatan/graphql-tools#451).
This is not necessarily just about cacheControl, but potentially about any directive not recognized by Graphcool, but useful 'downstream', like the new stream directive, or any other for that matter.

@Nighthawk14
Copy link

Any news on keeping those directives when stitching schemas together? Thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Development

No branches or pull requests

2 participants