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

[RFC] Directive proposal for opting out of null bubbling #1050

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

benjie
Copy link
Member

@benjie benjie commented Oct 5, 2023

This PR builds on #1048, so you should see the diff from that PR:

benjie/graphql-spec@asterisk...benjie:graphql-spec:no-null-bubbling

This introduces a directive on operations that disables the null/error propagation behavior by treating all Non-Null types as if they were Null-Only-On-Error types (see #1048).

The specific name of this directive (currently @nullOnError) is open to workshopping:

  • @noBubblesPlz 😉 or @tepid 🤣
  • @disableNullPropagation / @disableErrorPropagation / @noNullPropagation / @noPropagation / etc
  • @localErrors
  • @dontHandleErrorsForMeIKnowWhatImDoing
  • {your suggestion here}

This PR currently only includes a description of the directive and an example; the implementation is yet to come (hence: draft).

@netlify
Copy link

netlify bot commented Oct 5, 2023

Deploy Preview for graphql-spec-draft ready!

Name Link
🔨 Latest commit e58ab2b
🔍 Latest deploy log https://app.netlify.com/sites/graphql-spec-draft/deploys/651e9d35c809180008a5458c
😎 Deploy Preview https://deploy-preview-1050--graphql-spec-draft.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@bbakerman
Copy link

in terms of naming - we have a proposed PR on graphql-java

graphql-java/graphql-java#3772

@errorHandling(onError : NULL) or @errorHandling(onError : PROPOGATE)

This is not merged (yet) but its a name suggestion I would like to link here

@benjie
Copy link
Member Author

benjie commented Dec 11, 2024

Another option:

enum __ErrorBehavior {
  """
  Non-nullable positions that error cause the error to propagate to the nearest nullable
  ancestor position. The error is added to the "errors" list.
  """
  PROPAGATE
  
  """
  Positions that error are replaced with a `null` and an error is added to the "errors"
  list.
  """
  NULL
  
  """
  If any error occurs, abort the entire request and just return the error in the "errors"
  list. (No partial success.)
  """
  ABORT
  
  """
  Positions that error are replaced with an inline representation of the error, and
  the path to the error is added to the "errorPaths" list.
  """
  INLINE
}

directive @behavior(onError: __ErrorBehavior! = PROPAGATE) on QUERY | MUTATION | SUBSCRIPTION

(To be clear: I'm not proposing to implement ABORT or INLINE - these are just examples to justify why we might consider using an enum rather than a boolean.)

Rather than going error-centric for this, I felt like a single directive to handle many behaviors might make sense. We could later expand this so that you can do things like @behavior(onDeprecated: ERROR, onError: ABORT).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
💭 Strawman (RFC 0) RFC Stage 0 (See CONTRIBUTING.md)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants