-
-
Notifications
You must be signed in to change notification settings - Fork 676
Apollo's schema hints (apollo cache integration) #75
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
Comments
AFAIK, For things like caching and other stuff there is a middlewares feature with custom decorators support 😉 |
Ok, I've done some research and looks like right now there's now way to register directives using
However, it looks like there's a possibility to add an integration with Apollo Cache - So in this case you can create a middleware with custom decorator that will do the same job placing cache hints into GraphQLResolveInfo. |
I've made a middleware for apollo-cache-control after reading this post, but I still don't understand how it's supposed to work. I've set the maxAge to 60 seconds. The middleware seems to be working because I can see the cacheControl data in the extension field from the response. But when I refresh the page within seconds, the resolver still queries the database.
|
I haven't used apollo-cache-control yet, you should try this way in a simple example using Unfortunately, I have one's hands tied and I can't do anything until registering directives by code will be available in |
I just read that apollo engine is required in order to work with cache control. I haven't set up apollo engine config in graphql yoga so I will try it later. |
The caching finally works by adding Apollo Engine. https://github.com/graphcool/graphql-yoga/blob/master/examples/apollo-engine/index.js
|
Thanks for the research 😉 I am going to add integration with |
I really can't work out what the syntax would be for adding cache directives, are there any good examples of this yet? |
Does anyone have an example for cache control with type-graphql? |
import { CacheHint } from 'apollo-cache-control';
then:
As you can see this way it's globally enabled. The official example didn't work unfortunately. And trying to make it work for resolvers individually wasn't successful. |
The apollo-cache-control package has been deprecated. Do you still use this solution @omar-dulaimi , or did you figure out another way? |
bump |
Uh oh!
There was an error while loading. Please reload this page.
I'd like to create my schema with: https://www.apollographql.com/docs/engine/caching.html#hints-to-schema so it would be nice if I could define any arbitrary graphql directive to be passed to the compiled schema.
Maybe like:
Which should result in
The text was updated successfully, but these errors were encountered: