-
-
Notifications
You must be signed in to change notification settings - Fork 577
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Grafast: introduce inhibitOnNull
#2015
Merged
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
…d person (no SQL)
…nt it being consumed if invalid (e.g. don't allow using a 'Post' node ID to fetch a 'Person' record).
🦋 Changeset detectedLatest commit: 1df652f The changes in this PR will be included in the next version bump. This PR includes changesets to release 15 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
5 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
Follow up to #2014, also addressing #2013.
This pull request builds on the new flag-based system and introduces a new (internal)
__FlagStep
which applies a particular flag mask to a dependency. This__FlagStep
can automatically go away in most cases, by merging into theaddDependency
call of the dependent, since all it does is adjust the "accepted" flags those flags can be applied to the underlying step instead.Building on
__FlagStep
we have the new (public)inhibitOnNull()
step. This step tells the system that if a null occurs then anything depending on this value should be inhibited (i.e. prevented from executing and just assumed to benull
). This is particularly useful for Relay: imagine we want to use a nodeID
for a condition, but we are specifically referencing a particular type (e.g.Person
); we can decode the Node ID and attempt to get a specification for that type, but if the Node ID is for an alternative type (e.g.Post
) or is invalid then there's no point continuing because we know the condition will always be falsy, and thus we can "inhibit" the step to which the condition is being applied, thereby causing it to skip execution.For PostGraphile users, you can think of this a little bit like a
STRICT
database function: for aSTRICT
function if any argument is null then the database knows the result will be null and thus does not need to execute.inhibitOnNull
is a little like that, but it only applies to a single argument.This PR also introduces
assertNotNull()
andtrap()
but they are not yet tested (more PRs to come).Performance impact
Improvement: don't bother to run the following code if you know that it will be invalidated by
null
.Security impact
None known.
Checklist
yarn lint:fix
passes.yarn test
passes.RELEASE_NOTES.md
file (if one exists).