Closed
Description
Problem
There is no specification on whether EnumTypeDefinition are sorted by Name
, and it causes friction for GQL clients who presume there is order.
Context
- EnumTypeDefinition makes no indication of ordering
- Ordering very is significant to clients who convert the stringly-GQL DSL to typed client SDKs
- example 1 (typescript): Allow sorting in enums to be disabled dotansimha/graphql-code-generator#6935 (comment)
- example 2 (ios/apollo gen):
- given an enum
enum { Xx Zz Yy }
- enum => union:
union Foo = Xx | Zz | Yy
- struct:
public struct AsXxOrZzOrYy: GraphQLSelectionSet {
- enum => union:
- given an enum
As observed from the above, ordering matters during codegen to GQL consumers. If a schema maintainer changed the enum to enum { Yy Xx Zz }
, some clients would see this as a breaking change in the status quo.
Discussion
- To help consumers/clients of GQL succeed, the spec should disambiguate ordering on
EnumTypeDefinition
.
Personal recommendation: enum
s and tagged unions alike are Set
s, thus intrinsically unordered. We should state as much. Equipped with this assertion, client libraries whom seek to do type generation should apply stable sorting.
Metadata
Metadata
Assignees
Labels
No labels