Experimental support for @semanticNonNull #4601
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.
This PR adds experimental support for
@semanticNonNull
as described in apollographql/specs#42. Which is part of a broader effort to explore semantic nullability in GraphQL as explored in RFC: SemanticNonNull type (null only on error) . This directive-based approach should allow us to experiment with the concepts and identify issues as we work to understand the viability of semantic nullability in GraphQL.Experimental
As this is still an experimental implementation, it's designed to be minimally invasive rather than ideal in terms of architecture or performance. As the feature/RFCs stabilize I would imagine we would bake this into the schema crate and data structures as a first class concept.
This flag will not be broadly safe to enable in Relay since by default fields that are null due to error are still surfaced to the user. This is only safe to enable if:
Missing Pieces
@semanticNonNullField
which allows a patching an existing type to define it's field's semantic nullabilitylevels
will simply panic.@semanticNonNullField
will simply be ignoredTest Plan
I also spun up a version of
grats-relay-example
using Grat's experimental support for@semanticNonNull
and was able to see it working end to end.Screen.Recording.2024-01-27.at.2.17.26.PM.mov