This repository has been archived by the owner on Jul 6, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 13
Refactor queries to allow for cascaded partial results #59
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This is to check whether a given type for a list may have nullable entries.
First of all, this gets rid of `readOperation`, because it's almost identical to `query`, which should save us some bytes. `readSelection` has been reimplemented. Instead of writing fields onto data directly, it now first stores them in `dataFieldValue`. At any point when we encounter an uncached field that is NOT nullable, we return undefined. This is done by checking `dataFieldValue` against the schema. This is now done in one place to save some space and the hassle of reading repetitive code. This works because we now represent uncached values as `undefined`, which has been done in the past, but has been removed. Hence: - When `dataFieldValue` is `undefined` and a field is nullable then we write `null` and continue - When `dataFieldValue` is `undefined` and a field is NOT nullable then we return `undefined` instead of `data` immediately - Otherwise we write the field as usual This is nice, because that means `undefined` cascades upwards and this same logic also applies to resolved links!
When no field has been set on Query and the result would've been partially complete, then return `undefined` for the entire Query.
kitten
force-pushed
the
feat/cascading-nulls
branch
from
September 4, 2019 18:18
ac5aa08
to
a777d7d
Compare
If we encounter an uncached, nullable field we'd set ctx.partial, but if we then later return early with undefined, that'd still be set! Instead we need to set it after iterating, so that early `return undefined` statements skip setting ctx.partial
JoviDeCroock
approved these changes
Sep 4, 2019
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is actually amazing
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
This builds upon #58 to allow us to cascade partial results upwards. The
query
logic has been simplified so uncached values are now handled in one place and are represented byundefined
. ThereadSelection
traverser can also early-returnundefined
when non-nullable fields are missing.This means that non-cached entries cascade upwards until we find a nullable field or hit the root. Also, early returns are now everywhere, so we don't continue walking any query that is obviously incomplete.
The non-schema-aware mode hasn't changed in behaviour and we don't have any perf regressions 👍
benchmark run to show that perf is the same as before