Replies: 7 comments
-
I write down useful information for a possible future implementation analysis: |
Beta Was this translation helpful? Give feedback.
-
I have implemented a first pr #701 related to APQ, the next chapter that if I can I would like to see is the caching. |
Beta Was this translation helpful? Give feedback.
-
FTR, basic APQ supported is now released with https://github.com/rebing/graphql-laravel/releases/tag/7.1.0 What it could support is regular HTTP caching as:
But yes, besides that, there no other kind of built-in caching support at the moment and everything is up to the imagination of the developers. I would say areas where caching is most effective:
There are likely other ways, but those two came to mind mind first to reduce triggering "expensive" parts of GraphQL. I'm reclassifying this as feature request issue! |
Beta Was this translation helpful? Give feedback.
-
I note my thoughts on this, to move forward on the topic I think it is important to first implement another "thorny" one, the directives (topic of which this package I find is left behind). |
Beta Was this translation helpful? Give feedback.
-
No objections against directives! Looks super user and super complex but also super interesting 😬 |
Beta Was this translation helpful? Give feedback.
-
FTR, this has now been implemented: #740 |
Beta Was this translation helpful? Give feedback.
-
@ajanini in the latest RC2 we've been working on a new "execution middleware" approach. The whole request of GraphQL query/mutation now flows through a pipe calling the middlewares in succession like this graphql-laravel/config/config.php Lines 222 to 228 in d9c4f12 This would allow caching like this example from the tests However, thinking about this more, the resolver middleware might almost be more appropriate, see https://github.com/rebing/graphql-laravel#resolver-middleware It can be applied on an individual query/mutation and you basically intercept the |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Versions:
I know I'm using old versions and upgrades are in the works.
Question:
I've been looking into setting up a caching system in my GraphQL API and I've done some basic stuff, including extending the GraphQL controller and storing JSON responses in Redis.
I'm not sure, however, how to deal with queries and mutations that should not be cached.
I was thinking of implementing an interface
ShouldCache
in individual queries and mutations, in a similar manner that Laravel uses theShouldQueue
interface, but I'm not sure how to check if the Query/Mutation class implements this in the Controller, since the execution of the query appears to be isolated in it's own service container.I had previously dealt with caching in the Query level, but the return values from the
resolve()
method is pretty complex and it defeats the purpose of caching just the final JSON response. That, and it seems messy to implement at this level.What are the best practices for caching and GraphQL? Should I use a different approach?
Thanks
Beta Was this translation helpful? Give feedback.
All reactions