At a glance
- Project
- GraphQL Spec
- Identifier
- #860
- Stage
- RFC 3 / Accepted
- Champion
- @benjie
- Updated
- 2025-06-19
- Latest activity
- Pull request merged on
- Source
- Pull request
Pull request description
Following on from #776 and based on the discussion in the GraphQL.js pull request I'm still uncomfortable with the single root field validation rule for subscription operations.
Currently the "single root field" algorithm sets variableValues to be the empty set and then calls CollectFields. To see the issue with this, consider the following subscription operation:
type Subscription {
mySubscriptionField1: Int
mySubscriptionField2: Int
mySubscriptionField3: Int
}
subscription TwoFieldsByDefault($bool: Boolean = true) {
mySubscriptionField1 @skip(if: $bool)
mySubscriptionField2 @include(if: $bool)
mySubscriptionField3 @include(if: $bool)
}
A call to CollectFields passing an empty map for {variableValues} will result in all selections with @skip directives being considered, and all selections with the @include directive being skipped. So according to the current validation rule, this operation is valid - it only has one field mySubscriptionField1 (which is not an introspection field) in the root selection set.
However, if you pass no variables at runtime, the runtime CollectFields() called during CreateSourceEventStream for the subscription operation will result in groupedFieldSet containing two selections (mySubscriptionField2 and mySubscriptionField3). This will result in a request error being raised: If groupedFieldSet does not have exactly one entry, raise a request error.
This catches the invalid operation at runtime rather than validation time, giving a false sense of security about the validity of a GraphQL operation that may fail by default.
No other validation rule in the entire of Section 5 references variableValues or calls CollectFields; but we already know that the root subscription selection set is very special (it's been discussed many times at the GraphQL Spec WG).
This PR proposes that @skip and @include are forbidden on root subscription selection sets.
:rotating_light: This is a breaking change since previously valid operations such as the following will now be marked as invalid:
subscription ThisIsFineDotJpg($bool: Boolean = true) {
mySubscriptionField1 @skip(if: $bool)
mySubscriptionField2 @include(if: $bool)
}
GraphQL.js PR: https://github.com/graphql/graphql-js/pull/3974
Timeline
June 2025
- Pull request merged on by leebyron
- Discussed in GraphQL WGNext Steps
Lee: Review and merge "prevent skip and include on the route subscription selection set" RFC
Zoom summary · GraphQL WG · 2025-06-05The team discussed several proposals and RFCs related to GraphQL specifications. Mark proposed updates to the spec and implementation, which Lee supported and encouraged for conclusion. Benjie presented updates on data collection trilogy and one-off tasks, which Lee approved for merging. Rob shared progress on execution result definitions, which Lee praised for improving the type system coherence. The team celebrated the completion of default value coercion rules, which Benjie and Lee had worked on for a long time. Lee committed to reviewing and merging several proposals, including prevent skip and include on route subscription and discussion section 3 type system and execution versus request error.
Zoom summary · GraphQL WG · 2025-06-05
May 2025
- @benjie committed "Merge branch 'main' into subscription-single-root-field" on
- Advanced to RFC 3 on by leebyron
- Discussed in GraphQL WG
The GraphQL specification Working group discussed the deprecation of old versions of GraphQL JS, the proposal for defining a GraphQL request's response, and the clarification of the types of GraphQL responses. They also discussed the implementation of one-off features in GraphQL, Java, and GraphQL.js, the prevention of skip and include on route subscription selection sets, and the default value coercion rules. The group also discussed the need for a source of truth for built-in scalars and introspection types, the syntax for defining schemas in GraphQL, and the issue of error propagation in GraphQL.
Zoom summary · GraphQL WG · 2025-05-01Lee and Benjie discussed the implementation of one-off features in GraphQL, Java, and GraphQL.js, with Benjie suggesting a final check before merging. They also discussed the prevention of skip and include on route subscription selection sets, with Benjie stating that it has already been merged into GraphQL.js. Lee expressed interest in revisiting subscriptions in general to improve clarity. Benjie then brought up the default value coercion rules, which he believed had been merged into GraphQL.js and was good to go. Martin added a discussion about making include deprecated, non-nullable, which Lee agreed to merge.
Zoom summary · GraphQL WG · 2025-05-01
April 2025
- On the agenda for GraphQL WG
11 listed attendees · 16 agenda items · 14 linked RFCs
- Let's set a July 1st deadline for spec release (2m, Benjie)
- Open Telemetry Sub Commitee announcement (2m, Pascal)
- Add 'extensions' to request (5m, Benjie) #976
- Provision for unknown request information (5m, Martin)
- Defer/Stream Updates (10m, Rob) DeferStream
- Benjie's editorial PRs (20m, Benjie)
- Clarify "before execution begins" (10m, Benjie and Martin)
- Disabling error propagation proposal (10m, Alex) #1153
- Reaching a consensus on Semantic Nullability (25m, Alex) SemanticNullability wg#1700 #1065
- Make includeDeprecated non-null (10m, Martin) #1142
- Please give feedback on the following (2m, Martin)
- Implementations may not deprecate a field that the interface hasn't deprecated (2m, Benjie) #1053
- Prevent @skip and @include on root subscription selection set (5m, Benjie) #860
- OneOf Input Objects (10m, Benjie) #825
- Default value coercion rules (15m, Benjie) #793
- Define Data Collections used in the spec (20m, Benjie) #1102 #1092 #1063
March 2025
- Top comment edited on by benjie
- On the agenda for GraphQL WG
15 listed attendees · 9 agenda items · 6 linked RFCs
- GraphQLConf WG sessions - call for opinions (5m, Benjie)
- Non-nullable includeDeprecated argument (5m, Martin) #1142
- GraphQL Open Telmetry Specification (5m, Pascal)
- Tone of voice (5m, Martin)
- Nullability Working Group status update (15m, Alex Reilly) SemanticNullability #1065
- Fragment-Arguments (10m, Jovi De Croock) #1081
- Forbid @skip and @include on subscription root selection (10m, Benjie) #860
- Let's cut a spec release... it's been 3+ years! (15m, Benjie)
- Defer/Stream updates (10m, Rob) DeferStream
February 2025
- 2 commits pushed on
- @benjie committed "Merge branch 'main' into subscription-single-root-field"
- @benjie committed "Fix algorithm format"
- On the agenda for GraphQL.js WG
6 listed attendees · 3 agenda items · 2 linked RFCs
- Nullability RFC implementation (15m, Alex Reilly)
- Releasing GraphQL v17 (10m, Jovi De Croock)
- Forbid @skip and @include directives in subscription root (10m, Benjie) #860
December 2023
- Advanced to RFC 2 on by mjmahone
- Discussed in GraphQL WG
Can we bump RFC to RFC2?
Meeting notes · GraphQL WG · 2023-12-07
May 2021
- Top comment edited on by benjie
- @benjie committed "Use a modified copy of the CollectFields algorithm" on
- Advanced to RFC 1 on by leebyron
- Discussed in GraphQL WG
Potential validation oversight - @skip/@include; see related RFC: graphql/graphql-spec/pull/860
Meeting notes · GraphQL WG · 2021-05-13Potential validation oversight - @skip/@include; see related RFC: graphql/graphql-spec/pull/860
Meeting notes · GraphQL WG · 2021-05-13
April 2021
- Advanced to RFC 0 on by leebyron
- Pull request created on by benjie
- Top comment edited on by benjie
- @benjie committed "Prevent @skip and @include on root subscription selection set" on