Custom Executor, staticOnly cache control #7978
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
staticOnly
to cache control plugin to reduce overhead of willResolveFieldWhy?
These changes are to optimize general execution time and especially execution time for larger payloads.
Here is a comparison of the response time with a increasing response size. You can see that compared to the Apollo baseline, using Apollo + graphql-jit + staticOnly cache control mode results in a more than twice as fast response time when getting to larger response sizes. Even with smaller response sizes, there is a notable difference in response time.
How?
Custom Executor
Version 4 of Apollo Server removed the
executor
argument. This was due to it being a "legacy" option that used to be used for the Gateway. However, in the process of removing it, it also removed the option to drop in something like graphql-JIT.GraphQL JIT is a drop in replacement for graphql-js when executing. It is pretty significantly faster when looking at benchmarks.
This change introduces an argument called
customExecutor
which allows it to be dropped in. E.g.:Static Only Cache Control
The Cache Control plugin plugin currently runs
willResolveField
on every single field. This can cause quite a bit of overhead, especially on larger response sizes. This hook is to allow for dynamic cache control hints to be set in resolvers.This change introduces a
staticOnly
argument (default: false) to theApolloServerPluginCacheControl
plugin which allows opting out of dynamic cache hints. E.g.: