At a glance
- Identifier: #1063
- Stage: RFC 2 / Draft
- Champion: @benjie
- Latest activity: Added to WG agenda on 2025-05-01
- Spec PR: https://github.com/graphql/graphql-spec/pull/1063
Spec PR description
UPDATE 2025-06-26: The motivation of this PR is to make introspection stable (and, related, to make printSchema() stable, and to make printSchema(buildSchema(printSchema(schema))) === printSchema(schema)).
UPDATE 2024-04-05: Following last night's WG meeting, this PR has been split into 3 parts, and is now PR 3 of 3 in the "data collections" trilogy stack
- #1102
- #1092
- #1063 (this one)
As raised by @cdaringe in #1062, enum values don't dictate an explicit order. On scanning through the spec in more detail, it turns out this is true of a few other things too.
Everything in SDL is implicitly ordered (since it's a textual representation, one thing after another) and everything in introspection is implicitly ordered (because it's represented via lists). E.g. in introspection, enumValues is a list, and a list is inherently ordered.
I feel it's an unwritten rule that GraphQL introspection should be stable (i.e. introspect the exact same schema twice with the exact same introspection query and the results should be the same). Thus, there should be an order (dictated by the schema designer), and I'd like to make that more explicit.
I researched the current status, and I think we can start to fix this with the few minor edits I made to the spec in this PR, in particular:
- changing from using the word
set(which is generally perceived as unordered) to the wordlist(which is always ordered), - specifying list for things that are currently ambiguous.
Generally this was achieved by copying text from similar things, e.g. the directive arguments copied from field arguments; input object fields copied from object fields.
I know that @IvanGoncharov has been very careful in graphql-js to ensure that ordering is stable, I believe he ensures that introspection -> SDL -> introspection always results in the same results.
Status before this PR (emphasis mine)
Object fields: ordered :white_check_mark:
GraphQL Objects represent a list of named fields, each of which yield a value of a specific type.
Object field arguments: ordered :white_check_mark:
Object field arguments are defined as a list of all possible argument names and their expected input types
Object interfaces: not declared? :disappointed:
An object type may declare that it implements one or more unique interfaces.
(I couldn't find anything in Section 3 declaring set/list.)
Input object fields: a "set" :x:
A GraphQL Input Object defines a set of input fields
Enum values: a "set" :x:
However Enum types describe the set of possible values
Directive arguments: not declared? :disappointed:
(I couldn't find anything in Section 3 declaring set/list.)
Timeline
- Added to WG agenda on 2025-05-01
- Added to WG agenda on 2025-04-03
- Commit pushed on 2024-07-01 by benjie: Clarify wording
- 3 commits pushed on 2024-06-12:
- benjie committed "Interface fields do not need to be implemented in order."
- benjie committed "Interfaces an object implements are ordered"
- benjie committed "Unions are ordered."
- Added to WG agenda on 2024-06-06
- 3 commits pushed on 2024-04-05:
- benjie committed "Define Data Collections used in the spec"
- benjie committed "Add recommendation to preserve order where possible"
- benjie committed "Be explicit about the ordering of data types"
- Added to WG agenda on 2024-04-04
- Mentioned in WG notes on 2024-04-01
- Added to WG agenda on 2024-01-04
- Spec PR created on 2023-11-21 by benjie