RFC X / Superseded

Allow clients to disable error propagation via request parameter

Opened on
Closed on

At a glance

Project
GraphQL Spec
Identifier
#1153
Stage
RFC X / Superseded
Champion
@benjie
Updated
2025-06-12
Latest activity
Advanced to RFC 1 on
Source
Related RFCs

Pull request description

Replaces:

  • #1050
  • #1145

Requires editorial to be merged first:

  • #1152

GraphQL.js implementation:


Please see this 60 second video on the motivation for this PR (the last few seconds of the video also covers "transitional non-null" which is a separate concern).

As agreed at the nullability working group, disabling error propagation is the future of error handling in GraphQL. Error propagation causes a number of issues, but chief among them are:

  1. It destroys useful data in the response.
  2. It makes it unsafe to store resulting data in normalized stores.

Clients such as Relay do not want error propagation to be a thing.

This has traditionally resulted in schema design best practices advising using nullable in positions where errors were expected, even if null was never a semantically valid value for that position. And since errors can happen everywhere, this has lead to an explosion of nullability and significant pain on the client side with developers having to do seemingly unnecessary null checks in loads of positions, or worse - unsafely bypassing the type safety.

The reason that GraphQL does error propagation is to keep it's "not null" promise in the event that an error occurs (and is replaced with null due to the way GraphQL responses are structured and limitations in JSON) in a non-nullable position.

It doesn't take much code on the client to prevent the client reading a null that relates to an error, graphql-toe can be used with almost any JavaScript or TypeScript based GraphQL client (not Relay, but it has @throwOnFieldError that you can use instead) and achieves this in 512 bytes gzipped - and that's with a focus on performance rather than bundle size.

This PR allows the client to take responsibility for error handling by specifying onError: "NO_PROPAGATE" as part of the GraphQL request, and thereby turns off error propagation behavior. This is also set as the recommended default for future schemas.

With clients responsible for error handling, we no longer need to factor the possibility of whether something can error or not into its nullability, meaning we can use the not-null ! to indicate all the positions in the schema for which null is not a semantically valid value - i.e. the underlying resource will never be a legitimate null.

The end result:

  • true nullability indicated in schema - no more thinking about where errors are likely
  • fewer null checks on clients
  • clients can leverage their native error handling capabilities such as try/catch or <ErrorBoundary />
  • safe to store errored responses into normalized stores (if the response comes back with errors: "NO_PROPAGATE")

I've also included onError: "ABORT" in this proposal. We've discovered that there's a small but significant class of clients out there, mostly ad-hoc scripts, that throw away the entire response when any error occurs. By codifying this into the spec we make it easier to implement these clients, and we allow the server to abort processing the rest of the request unnecessarily.

Timeline

June 2025

April 2025

  • Pull request closed on
  • Advanced to RFC 1 on by leebyron
  • Discussed in GraphQL WG

    The GraphQL working group meeting focused on the importance of the membership agreement, participation and contribution guidelines, and code of conduct, with a round of introductions and an extensive agenda. The group discussed changes to the GraphQL specification regarding terminology and error handling, refactoring the execution algorithms, and the nullability working group's consensus on disabling null propagation. They also considered various approaches to handling nullability and error management in GraphQL schemas, with a preference for directive-based solutions over syntax changes.

    Zoom summary · GraphQL WG · 2025-04-03

    The group discusses the nullability working group's consensus on disabling null propagation. They have agreed on Benjie's request parameter solution, which is considered cleaner than the previous query directive approach. This solution allows for potentially defaulting the option to true in future schema versions. The proposal aims to address issues with null propagation and support clients like Relay with normalized caches. The group plans to seek either stage 2 or stage 3 approval at the next working group meeting. Lee suggests aiming for RFC1 to confirm agreement on the problem being solved. Benjie invites feedback on naming conventions for the error handling options.

    Zoom summary · GraphQL WG · 2025-04-03

March 2025