[RFC] Cache parsed and validated queries in memory #2170
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.
A first RFC to kick off a discussion about caching parsed and validated
queries. This is based on the ideas from graphql/graphql-js#158
GraphQL APIs often get the same queries with different variables over
and over. Even though the query string doesn't change, Apollo server
parses and validates it on every request.
Instead, we can cache the resulting AST and skip the parsing and
validation step on further requests with the same query. While I don't
think this will provide an order of magnitude of a speedup, it seems
like it would avoid unnecessary work, could help in performance
sensitive scenarios and doesn't add much complexity.
This PR implements this in a very crude way to kick off a discussion
about including this in Apollo Server.
TODO: