Skip to content

spec change: allow empty selection sets - #4852

Merged
yaacovCR merged 8 commits into
17.x.xfrom
empty-selection-sets
Oct 14, 2026
Merged

yaacovCR merged 8 commits into
17.x.xfrom
empty-selection-sets

Conversation

@martinbonnin

@martinbonnin martinbonnin commented Aug 31, 2026 •

Copy link
Copy Markdown
Contributor

See graphql/graphql-spec#1227

There is a new (and already deprecated!) parser/validation option allowEmptySelectionSets. It is true by default (new behaviour). Set it to false to switch back to the old behaviour.

@vercel

vercel Bot commented Aug 31, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
graphql-js Ignored Ignored Preview Oct 14, 2026 11:52am UTC

Request Review

@magicmark magicmark left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🥳

@benjie benjie left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Solid changes 👍

Comment thread src/validation/validate.ts Resolved
Comment thread src/validation/ValidationContext.ts Resolved
@martinbonnin
martinbonnin requested a review from benjie September 3, 2026 14:58

@benjie benjie left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM; the options object does add some garbage collection overhead so @yaacovCR might want to trigger the benchmarks, but I imagine it's an incredibly lightweight cost so unlikely to be a big deal.

@martinbonnin martinbonnin changed the title Allow empty selection sets Allow empty selection sets - experimental flag version Sep 4, 2026
@martinbonnin martinbonnin changed the title Allow empty selection sets - experimental flag version Allow empty selection sets - flag version Sep 4, 2026
@glen-84

glen-84 commented Sep 8, 2026

Copy link
Copy Markdown

With the parser now accepting { }, subscription { } parses and validates cleanly, but I think it should still fail validation.

The spec's Single Root Field rule says the collected fields map "must have exactly one entry", and this PR doesn't change that rule. SingleFieldSubscriptionsRule only checks the upper bound though:

if (groupedFieldSet.size > 1) {

That was enough while the grammar guaranteed at least one selection. Now it lets an empty subscription through, and the same goes for subscription { ...Empty } with an empty fragment, since that also collects to zero fields.

Suggestion: report when groupedFieldSet.size === 0 as well, e.g. Subscription "X" must select a top level field. (or fold both into size !== 1), plus a case in SingleFieldSubscriptionsRule-test.ts for the empty operation and the empty-fragment variant.

For reference, Hot Chocolate's implementation of this change (ChilliCream/graphql-platform#10337) allows empty selection sets on query and mutation roots and on composite fields, but keeps rejecting an empty subscription root.

Drafted by Claude (Anthropic AI assistant).

benjie added a commit to graphql/graphql-spec that referenced this pull request Sep 10, 2026
@martinbonnin

Copy link
Copy Markdown
Contributor Author

@glen-84 sorry I forgot to reply here but the case where a subscription has no root field is now handled in this PR. Thank you and Claude for catching it.

@martinbonnin

Copy link
Copy Markdown
Contributor Author

@yaacovCR the spec is merged, can we merge this one?

@yaacovCR yaacovCR changed the title Allow empty selection sets - flag version spec change: allow empty selection sets Oct 14, 2026
@yaacovCR
yaacovCR merged commit 7d3fe64 into 17.x.x Oct 14, 2026
42 checks passed
@yaacovCR
yaacovCR deleted the empty-selection-sets branch October 14, 2026 11:54
@yaacovCR yaacovCR added spec RFC Implementation of a proposed change to the GraphQL specification PR: feature 🚀 requires increase of "minor" version number labels Oct 14, 2026
@yaacovCR yaacovCR mentioned this pull request Nov 4, 2026
yaacovCR added a commit that referenced this pull request Nov 4, 2026
## v17.1.0 (2026-11-04)

#### New Feature 🚀
* [#4852](#4852) spec change: allow empty selection sets ([@martinbonnin](https://github.com/martinbonnin))
* [#4905](#4905) feat: add maxComments parser option ([@yaacovCR](https://github.com/yaacovCR))
* [#4906](#4906) feat: add maxSourceLength parser option ([@yaacovCR](https://github.com/yaacovCR))
* [#4950](#4950) feat: configure list type nesting in the parser ([@yaacovCR](https://github.com/yaacovCR))
* [#4953](#4953) feat: configure printer indentation depth ([@yaacovCR](https://github.com/yaacovCR))

#### Bug Fix 🐞
* [#4837](#4837) fix(VariablesInAllowedPositionRule): allow fragments with variables prior to operations ([@yaacovCR](https://github.com/yaacovCR))
* [#4838](#4838) fix(DeferStreamDirectiveOnRootFieldRule): handle fragment cycles ([@yaacovCR](https://github.com/yaacovCR))
* [#4839](#4839) fix(OverlappingFieldsCanMergeRule): require same variable definitions ([@yaacovCR](https://github.com/yaacovCR))
* [#4853](#4853) fix(OverlappingFieldsCanMerge): fix var scope for fragment comparison cache ([@yaacovCR](https://github.com/yaacovCR))
* [#4841](#4841) Skip deferred fragments in collectFields only when same directive is used ([@robrichard](https://github.com/robrichard))
* [#4859](#4859) test(incremental): document bugs in shared deferred work ([@duckki](https://github.com/duckki))
* [#4868](#4868) fix(incremental): prevent lost or delayed successful shared results ([@yaacovCR](https://github.com/yaacovCR))
* [#4869](#4869) fix(incremental): prevent error completions for unannounced fragments ([@yaacovCR](https://github.com/yaacovCR))
* [#4865](#4865) fix(validation): keep argument defaults inside fragments ([@SashaMIT](https://github.com/SashaMIT))
* [#4879](#4879) fix(validation): keep collected fields separate by parent type ([@yaacovCR](https://github.com/yaacovCR))
* [#4895](#4895) fix(validation): bound conflict descriptions ([@yaacovCR](https://github.com/yaacovCR))
* [#4896](#4896) fix(validation): bound nested conflict locations ([@yaacovCR](https://github.com/yaacovCR))
* [#4898](#4898) perf(validation): prepare fragment spreads only for comparisons ([@yaacovCR](https://github.com/yaacovCR))
* [#4897](#4897) feat(validation): limit overlapping field complexity ([@yaacovCR](https://github.com/yaacovCR))
* [#4903](#4903) fix: rename maxTokens to maxLexicalTokens ([@yaacovCR](https://github.com/yaacovCR))
* [#4904](#4904) memoize pathToArray to reduce memory for multiple defers at the same path ([@robrichard](https://github.com/robrichard))
* [#4908](#4908) fix: pass parser options through buildSchema ([@yaacovCR](https://github.com/yaacovCR))
* [#4916](#4916) fix: bound shared fragment traversal in introspection validation ([@yaacovCR](https://github.com/yaacovCR))
* [#4929](#4929) fix: initialize subscription validation variables ([@yaacovCR](https://github.com/yaacovCR))
* [#4937](#4937) fix: skip disabled argument suggestions ([@yaacovCR](https://github.com/yaacovCR))
* [#4946](#4946) refactor: track fragment validation work ([@yaacovCR](https://github.com/yaacovCR))
* [#4949](#4949) refactor: account for subscription field collection ([@yaacovCR](https://github.com/yaacovCR))
* [#4951](#4951) refactor: account for field return type comparisons ([@yaacovCR](https://github.com/yaacovCR))
* [#4915](#4915) fix: align minified source location at chunk boundaries ([@fallintoplace](https://github.com/fallintoplace))
* [#4977](#4977) fix: keep minified EOF carets after the final character ([@yaacovCR](https://github.com/yaacovCR))
* [#4979](#4979) fix: reference ESM source maps from every emitted module ([@yaacovCR](https://github.com/yaacovCR))
* [#4980](#4980) fix: identify ESM modules in source map metadata ([@yaacovCR](https://github.com/yaacovCR))
* [#4983](#4983) fix: avoid inherited variable getters in nested literal values ([@yaacovCR](https://github.com/yaacovCR))

#### Docs 📝
<details>
<summary> 4 PRs were merged </summary>

* [#4986](#4986) docs: refresh the v16 and v17 API references ([@yaacovCR](https://github.com/yaacovCR))
* [#4987](#4987) docs: render constructor examples in the API reference ([@yaacovCR](https://github.com/yaacovCR))
* [#4988](#4988) docs: generate API reference during website builds ([@yaacovCR](https://github.com/yaacovCR))
* [#4989](#4989) docs: list v17 first in the API sidebar ([@yaacovCR](https://github.com/yaacovCR))
</details>

#### Polish 💅
<details>
<summary> 69 PRs were merged </summary>

* [#4836](#4836) refactor: add map keyed by set membership ([@yaacovCR](https://github.com/yaacovCR))
* [#4843](#4843) polish(OverlappingFieldsCanMerge: add tests documenting existing behavior ([@yaacovCR](https://github.com/yaacovCR))
* [#4855](#4855) refactor(validation): add overlapping fields rule context ([@yaacovCR](https://github.com/yaacovCR))
* [#4856](#4856) refactor(validation): name the variable map type ([@yaacovCR](https://github.com/yaacovCR))
* [#4857](#4857) polish(validation): skip empty field comparisons ([@yaacovCR](https://github.com/yaacovCR))
* [#4851](#4851) test: accept non-null union implementing a nullable union ([@jayphelps](https://github.com/jayphelps))
* [#4845](#4845) polish(validateInputValue): cover invalid values in iterable input ([@vrana055](https://github.com/vrana055))
* [#4844](#4844) polish(introspection): cover __Type.description on wrapping types ([@vrana055](https://github.com/vrana055))
* [#4860](#4860) docs: fix incorrect API doc examples and copy-pasted descriptions ([@Cito](https://github.com/Cito))
* [#4867](#4867) refactor(incremental): extract maybeFinishGroup ([@yaacovCR](https://github.com/yaacovCR))
* [#4871](#4871) refactor(validation): rename NodeAndDef to FieldDetails ([@yaacovCR](https://github.com/yaacovCR))
* [#4872](#4872) refactor(validation): name field detail lists ([@yaacovCR](https://github.com/yaacovCR))
* [#4873](#4873) refactor(validation): rename NodeAndDefCollection to GroupedFieldSet ([@yaacovCR](https://github.com/yaacovCR))
* [#4874](#4874) refactor(validation): align field collection names with execution ([@yaacovCR](https://github.com/yaacovCR))
* [#4875](#4875) refactor(validation): convert FieldDetails tuples to objects ([@yaacovCR](https://github.com/yaacovCR))
* [#4876](#4876) refactor(validation): convert CollectFieldsResult tuples to objects ([@yaacovCR](https://github.com/yaacovCR))
* [#4877](#4877) refactor(validation): convert conflict tuples to objects ([@yaacovCR](https://github.com/yaacovCR))
* [#4878](#4878) refactor(validation): make unordered pair lookup independent of key order ([@yaacovCR](https://github.com/yaacovCR))
* [#4880](#4880) refactor(validation): rename VariableMap to VariableScope ([@yaacovCR](https://github.com/yaacovCR))
* [#4881](#4881) perf(validation): share field collections across scopes ([@yaacovCR](https://github.com/yaacovCR))
* [#4882](#4882) refactor(validation): check stream overlap in findConflict ([@yaacovCR](https://github.com/yaacovCR))
* [#4883](#4883) perf(validation): prepare field comparison data together ([@yaacovCR](https://github.com/yaacovCR))
* [#4885](#4885) perf(validation): reuse scope maps across equivalent fragment spreads ([@yaacovCR](https://github.com/yaacovCR))
* [#4886](#4886) refactor(validation): compare value structure directly ([@yaacovCR](https://github.com/yaacovCR))
* [#4888](#4888) refactor(validation): compare variable scope identities ([@yaacovCR](https://github.com/yaacovCR))
* [#4889](#4889) perf(validation): cache field-pair source comparisons ([@yaacovCR](https://github.com/yaacovCR))
* [#4890](#4890) perf(validation): cache source value preparation ([@yaacovCR](https://github.com/yaacovCR))
* [#4891](#4891) perf(validation): cache value scope dependencies ([@yaacovCR](https://github.com/yaacovCR))
* [#4892](#4892) perf(validation): cache source fragment spread preparation ([@yaacovCR](https://github.com/yaacovCR))
* [#4893](#4893) perf(validation): reuse matching response groups across scopes ([@yaacovCR](https://github.com/yaacovCR))
* [#4894](#4894) perf(validation): skip redundant inline selection-set checks ([@yaacovCR](https://github.com/yaacovCR))
* [#4902](#4902) perf: avoid repeated SetMap key construction ([@yaacovCR](https://github.com/yaacovCR))
* [#4920](#4920) perf: reuse fragment dependencies across operations ([@yaacovCR](https://github.com/yaacovCR))
* [#4921](#4921) perf: reuse fragment variable usages ([@yaacovCR](https://github.com/yaacovCR))
* [#4925](#4925) perf: share fragment collection across operations ([@yaacovCR](https://github.com/yaacovCR))
* [#4926](#4926) refactor: use context fragment lookups in directive validation ([@yaacovCR](https://github.com/yaacovCR))
* [#4927](#4927) perf: share subscription fragment lookups ([@yaacovCR](https://github.com/yaacovCR))
* [#4931](#4931) perf: reuse subscription directive paths ([@yaacovCR](https://github.com/yaacovCR))
* [#4932](#4932) perf: reuse introspection fragment checks ([@yaacovCR](https://github.com/yaacovCR))
* [#4933](#4933) perf: share completed directive checks ([@yaacovCR](https://github.com/yaacovCR))
* [#4935](#4935) test: cover source location lookups ([@yaacovCR](https://github.com/yaacovCR))
* [#4936](#4936) perf: share source location lookups ([@yaacovCR](https://github.com/yaacovCR))
* [#4938](#4938) perf: reuse required fragment arguments ([@yaacovCR](https://github.com/yaacovCR))
* [#4939](#4939) perf: remove an extra list item type check ([@yaacovCR](https://github.com/yaacovCR))
* [#4940](#4940) perf: reuse identical field return types ([@yaacovCR](https://github.com/yaacovCR))
* [#4941](#4941) perf: reuse field return type names ([@yaacovCR](https://github.com/yaacovCR))
* [#4942](#4942) perf: index directive argument names ([@yaacovCR](https://github.com/yaacovCR))
* [#4943](#4943) perf: index directive locations ([@yaacovCR](https://github.com/yaacovCR))
* [#4944](#4944) perf: reuse field return type descriptions ([@yaacovCR](https://github.com/yaacovCR))
* [#4945](#4945) perf: reuse supported AST kinds ([@yaacovCR](https://github.com/yaacovCR))
* [#4947](#4947) refactor: extract visitSelectionSets ([@yaacovCR](https://github.com/yaacovCR))
* [#4948](#4948) refactor: simplify referenced fragment collection ([@yaacovCR](https://github.com/yaacovCR))
* [#4952](#4952) refactor: stream printer output ([@yaacovCR](https://github.com/yaacovCR))
* [#4956](#4956) perf: skip unused argument lookup preparation ([@yaacovCR](https://github.com/yaacovCR))
* [#4957](#4957) perf: skip required argument preparation for argument-free fields ([@yaacovCR](https://github.com/yaacovCR))
* [#4958](#4958) perf: scan single source locations directly ([@yaacovCR](https://github.com/yaacovCR))
* [#4959](#4959) perf: store visitor edits in a flat array ([@yaacovCR](https://github.com/yaacovCR))
* [#4960](#4960) perf: skip selection sets with no fields to compare ([@yaacovCR](https://github.com/yaacovCR))
* [#4961](#4961) perf: allocate visitor edits only when needed ([@yaacovCR](https://github.com/yaacovCR))
* [#4963](#4963) perf: reuse the visitor array check ([@yaacovCR](https://github.com/yaacovCR))
* [#4964](#4964) perf: skip pair metadata for compatible leaf fields ([@yaacovCR](https://github.com/yaacovCR))
* [#4965](#4965) perf: prepare type name lookups only when needed ([@yaacovCR](https://github.com/yaacovCR))
* [#4972](#4972) perf: flatten input-value printing ([@yaacovCR](https://github.com/yaacovCR))
* [#4973](#4973) perf: avoid arrays for single-line printer text ([@yaacovCR](https://github.com/yaacovCR))
* [#4974](#4974) perf: assemble printer output as a string ([@yaacovCR](https://github.com/yaacovCR))
* [#4975](#4975) perf: skip empty printer work ([@yaacovCR](https://github.com/yaacovCR))
* [#4976](#4976) perf: add a minimal AST reducer for printing ([@yaacovCR](https://github.com/yaacovCR))
* [#4971](#4971) perf: reuse fragment checks from fields exceeding the introspection depth ([@Cito](https://github.com/Cito))
* [#4982](#4982) revert: remove maxListDepth from #4950 for now ([@yaacovCR](https://github.com/yaacovCR))
</details>

#### Internal 🏠
<details>
<summary> 13 PRs were merged </summary>

* [#4884](#4884) ci: use a stable language-based CodeQL category ([@yaacovCR](https://github.com/yaacovCR))
* [#4887](#4887) ci: run CodeQL in a dedicated workflow ([@yaacovCR](https://github.com/yaacovCR))
* [#4907](#4907) test: execute JSDoc API examples with Node ([@yaacovCR](https://github.com/yaacovCR))
* [#4912](#4912) internal: robustify examples test runner ([@yaacovCR](https://github.com/yaacovCR))
* [#4928](#4928) ci: shard integration tests across eight jobs ([@yaacovCR](https://github.com/yaacovCR))
* [#4954](#4954) ci: retire Node.js 25 ([@yaacovCR](https://github.com/yaacovCR))
* [#4955](#4955) ci: test Node.js 27 prereleases ([@yaacovCR](https://github.com/yaacovCR))
* [#4967](#4967) fix: accept zero-byte benchmark memory samples ([@yaacovCR](https://github.com/yaacovCR))
* [#4968](#4968) fix: collect warmup garbage before benchmark memory samples ([@yaacovCR](https://github.com/yaacovCR))
* [#4970](#4970) benchmark: cover schema document printing ([@yaacovCR](https://github.com/yaacovCR))
* [#4969](#4969) fix: use cumulative allocation counters in memory benchmarks ([@yaacovCR](https://github.com/yaacovCR))
* [#4978](#4978) build: remove the obsolete development entry point ([@yaacovCR](https://github.com/yaacovCR))
* [#4981](#4981) internal: further improve example test runner ([@yaacovCR](https://github.com/yaacovCR))
</details>

#### Committers: 9
* Christoph Zwerschke([@Cito](https://github.com/Cito))
* Duckki Oe([@duckki](https://github.com/duckki))
* Jay Phelps([@jayphelps](https://github.com/jayphelps))
* Martin Bonnin([@martinbonnin](https://github.com/martinbonnin))
* Minh Vu([@fallintoplace](https://github.com/fallintoplace))
* Rob Richard([@robrichard](https://github.com/robrichard))
* Sash([@SashaMIT](https://github.com/SashaMIT))
* Vibhanshu Rana([@vrana055](https://github.com/vrana055))
* Yaacov Rydzinski ([@yaacovCR](https://github.com/yaacovCR))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

PR: feature 🚀 requires increase of "minor" version number spec RFC Implementation of a proposed change to the GraphQL specification

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants