Skip to content
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

Experimental support for @semanticNonNull #4601

Closed
wants to merge 4 commits into from
Closed

Conversation

captbaritone
Copy link
Contributor

@captbaritone captbaritone commented Jan 27, 2024

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:

  1. Your network layer discards all payloads that have any field errors
  2. You enable our explicit error handling feature, which is still itself experimental.

Missing Pieces

  • Documentation about how to use this feature (purposeful, since this is experimental)
  • Support for @semanticNonNullField which allows a patching an existing type to define it's field's semantic nullability
  • Validation
    • Invalid use of levels will simply panic.
    • Uses of @semanticNonNullField will simply be ignored
    • There is no schema validation ensuring interface types have type-compatible semantic nullability

Test Plan

cargo test

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

@facebook-github-bot
Copy link
Contributor

@captbaritone has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Contributor

@captbaritone merged this pull request in cebc7f0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants