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.
Add an alternate cache that reads the selections from
operation.document
instead of using codegen andCompiledField
.This trades codegen for runtime parsing. Current thoughts:
addTypename
needs to be"always"
if we don't want to codegen the full type definitions. This is a sensible default when using the cache anyways because a given object type might be accessed from an interface.GQLField
has no type (again because we don't want to codegen the full type definitions), it's impossible to tell if a JSON object is scalar or not, which means scalar encoded directly in the JSON will now create intermediate records. Not 100% sure how much of a problem that is.CompiledField
is a public API incacheKeyGenerator
. If some people rely onrawType()
this is going to be a problem. On the other hand I think usingrawType()
is a mistake in most cases as what's included in the cache key is__typename
instead.GQLField
instead ofCompiledField
Current microbenchmarks (query1 is using CompiledField, query2 is using AST):
While it's slower, microbenchmarks are not very representative because it parses the document every loop while the
CompiledField
is built only once during classloading and kept in memory after that.