Add Transitional Non-Null appendix (@noPropagate
directive)
#1165
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 is essentially solution 8 to the Semantic Nullability RFC:
I've based it on:
since, like all solutions to the semantic nullability problem1, it is designed to enable clients with error propagation disabled to leverage the true nullability of the underlying data without breaking legacy clients. The approach could be rebuilt atop an alternative method of toggling error propagation, for example a directive-based approach.
This PR introduces an appendix to the GraphQL specification defining an optional solution to the semantic nullability problem using the following key mechanisms:
@noPropagate
2 directive — allows schema authors to annotateNon-Null
return types as transitional, suppressing propagation but preserving runtime error generation.__Field.noPropagateLevels: [Int!]
field — exposes transitional status to modern clients.PROPAGATE
error behavior will get results from__Field.type
that unwrap transitional non-null types.3This solution attempts to address all of the feedback on previous solutions to this problem, whilst being explicitly transitional. It:
@noPropagate
), regardless of whether error propagation is enabled or disabled.!
(non-null) directly for semantically non-null positions!
(non-null) for error handling clients without breaking legacy clients by adding the@noPropagate
directive4@noPropagate
to all nullable positions.Footnotes
Except solution 5 ↩
This is essentially the same as the
@semanticNonNull
directive, but more strictly defined and reflected through introspection. ↩This may be controversial, but I truly think it's the right decision. All new tooling (and all new clients!) should use
onError: ABORT
oronError: NO_PROPAGATE
, and thus will see the true introspection. Existing tooling doesn't know aboutonError
and so should not see these "transitional" non-null types. ↩And if you forget to add it, adding it later is only a potentially breaking change for any new versions of legacy clients deployed since the change; error-handling clients (
NO_PROPAGATE
orABORT
) are unimpacted. ↩