RFC 1 / Proposal

Introduce Strict and Legacy All Variable Usages Are Allowed

Opened on
Updated on

At a glance

Project
GraphQL Spec
Identifier
#1059
Stage
RFC 1 / Proposal
Champion
@benjie
Updated
2026-11-05
Latest activity
Added to WG agenda on
Source

Pull request description

For the following schema:

type Query {
  sum(numbers:[Int!]!): Int
}

The following query is currently valid:

query Q ($number: Int = 3) {
  sum(numbers: [1, $number, 3])
}

This query will accept the variables {"number": null} and result in a runtime field error when it turns out that null cannot be used in this non-nullable list value position. This was discussed in depth in the December 2022 Secondary EU WG meeting, resulting in this action item https://github.com/graphql/graphql-wg/issues/1337. Timestamped link to the relevant part of the discussion: https://youtu.be/nkPn-F_UBJo?list=PLP1igyLx8foH30_sDnEZnxV_8pYW3SDtb&t=2702

This PR implements the agreed solution: it introduces a stricter version of the All Variable Usages Are Allowed algorithm which forbids a nullable variable from being used in a non-nullable position; and to support existing documents a legacy version of the old algorithm is maintained (basically a copy/paste).

Under the new strict algorithm, the previous query becomes invalid and you'd need to make the variable type non-nullable:

query Q ($number: Int! = 3) {
  sum(numbers: [1, $number, 3])
}

This still allows the variable $number to be omitted, but it does not allow it to be explicitly null.

IMPORTANT NOTE: this new algorithm does not allow an argument/input object field's default value to be used if a variable is used as the value for that argument/input object field. A workaround is to copy the argument/input object field's default value to the variable definition, but this will mean that changes to the argument/input object field's default value will not be reflected by existing queries. I think this is acceptable, since there's no way to leverage the default value of an argument when passing a literal to it either - I'm in favour of literal/variable equivalence where possible, and I think that the benefits of turning this runtime error into a validation error outweigh the costs.

cc @leebyron @mjmahone @IvanGoncharov as they were participants in the discussion above and contributed to this decision.

Timeline

November 2026

  • Discussed in GraphQL WG

    The GraphQL Foundation working group meeting focused on several key proposals and discussions. Leif presented a proposal to create a Java Special Interest Group (SIG) to bring together Java companies and maintainers interested in GraphQL, with support from companies like Netflix, Airbnb, and various Java GraphQL implementations. Dale discussed a proposal for standardizing how agents search GraphQL schemas, which led to a detailed conversation about handling empty object types, interfaces, and unions, with the group ultimately favoring option A that uses type T with curly braces to indicate empty types while maintaining consistency across most syntax except for unions. Andy presented two items: a pull request to clarify error location specifications in the GraphQL specification regarding Unicode code points and column calculations, and a proposal to implement stricter variable usage validation rules that was originally discussed three years ago but never fully implemented. The conversation ended with welcome messages for first-time attendees Dale and Leif.

    Zoom summary · GraphQL WG · 2026-11-05
    Next Steps

    andi: Create a GraphQL JS pull request to implement the new validation rule for nullable variables with default values used as input to non-nullable arguments.

    Zoom summary · GraphQL WG · 2026-11-05
    Next Steps

    andi: Investigate how GraphQL JS currently handles logging to see if it's possible to log queries that would be invalid under the new rule.

    Zoom summary · GraphQL WG · 2026-11-05

    The team discussed proposals for handling empty unions in GraphQL schema definitions. Leebyron and Benjie debated syntax options, with Leebyron favoring option A (allowing empty unions) despite breaking consistency with existing rules, while Benjie suggested deprecating unions entirely. The group agreed to allow empty unions with syntax using double curly braces, though this would require breaking some tooling compatibility. Andy presented a pull request to clarify error location specifications in the GraphQL specification, particularly regarding Unicode code points and column calculations. The team also discussed a 3-year-old proposal from Benjie regarding stricter validation rules for nullable variables with default values, which Andy agreed to implement in GraphQL.js with both legacy and new rule options available.

    Zoom summary · GraphQL WG · 2026-11-05

December 2023

November 2023