RFC 3 / Accepted

Add 'extensions' to request

Opened on
Merged on

At a glance

Project
GraphQL Spec
Identifier
#976
Stage
RFC 3 / Accepted
Champion
@benjie
Updated
2025-04-17
Latest activity
Pull request merged on
Source

Pull request description

It's common in the ecosystem to use extensions on a GraphQL request to share additional information with the server; for example Apollo Persisted Queries uses it to indicate the hash of the document to execute.

Currently the GraphQL Spec specifies an "extensions" field on Response but not on Request; I'm trying to determine if this is a purely transport-level concern (i.e. should be specified in GraphQL-over-HTTP, etc), or if it should be specified in the spec proper. IMO the spec should have at least a note indicating the use of the "extensions" field.

The specification of the format of a request is somewhat fuzzier than the format of a response; this is not unexpected because GraphQL is so flexible in how it is consumed, and persisted operations/etc should be spec compliant without having to be specified therein. So the request doesn't really speak of specific keys, more here's the information we need to execute, and "extensions" is not amongst that information. Nonetheless, standardising extensions as a key for expansion would be beneficial to the community.

It's worth noting that GraphQL.js does not include extensions amongst the arguments to graphql(): https://github.com/graphql/graphql-js/blob/699ec58547c34bfeef866a2a4458615d39b16964/src/graphql.ts#L20-L68 . Nor does express-graphql look at extensions on a request as far as I can tell.

Timeline

April 2025

  • Pull request merged on by leebyron
  • @leebyron committed "Update Section 6 -- Execution.md" on
  • Advanced to RFC 3 on by leebyron
  • Discussed in GraphQL WG

    In the meeting, Benjie proposed a spec cut with a deadline of July 1st, aiming for a release by September. Lee expressed enthusiasm for this plan, aiming for a new spec cut at or before the GraphQLConf in the fall. Pascal discussed the interest in the open telemetry specification and proposed a short lift subcommittee for it. Benjie raised the issue of adding an extensions property to the request, which was approved. Martin discussed the need to explicitly forbid implementations from choking on unknown fields. Michael suggested this was more relevant to the HTTP spec. The team agreed to standardize on "result map" in the algorithm.

    Zoom summary · GraphQL WG · 2025-04-03

January 2025

December 2024

July 2024

  • Discussed in GraphQL WG

    Adding "extensions" to request (5m, Benjie)

    • Benjie: Split into two PRs:
      • Define names of params of GraphQL request (merged)
      • Should we add this additional definition of extensions (the current PR)
    • Benjie: Other transports that use different encodings need to understand what constraints there are on the extensions data.
    • Benjie: Specifies that there may or may not be extensions and if it does exist it should be a map.
    • Martin: Do we want to reserve namespaces in the extensions map for sub-specs? Would allow sub-spec authors to add their own metadata without needing to make it a GraphQL core spec change.
    • Benjie: GraphQL Foundation owns the namespace. We can probably have those conversations globally since there’s enough overlap between main spec WG and sub-spec authors.
    • Martin: People are using top level names for persisted documents (documentID)
    • Benjie: I think GraphQL spec additions should live outside of extensions and leave extensions for users
    Meeting notes · GraphQL WG · 2024-07-18

April 2024

March 2024

September 2022

August 2022