-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
On specifying ordered vs unordered enum definitions #1062
Comments
Good catch. In my opinion, like fields, they should be in the order in which they were defined, which effectively means tools are free to make their own decisions. Either way, the order should be stable in my opinion:
The results of 1 and 3 should be identical. |
@benjie! long time, no-GitHub-see :)
Just to clarify, are you asserting that you think, in the spec, |
We've been occasionaly hit by such sorting issues in Apollo Kotlin and the more I think about it the more I think the "good" order for tools is the schema order. Everything else is surprising and error prone. Sorting codegen by name is dangerous because the schema author doesn't control the sorting anymore so adding an enum starting with "a" offsets all the subsequent ones. All in all, my favorite solution is to keep things as is and have tools that analyze schema changes output a warning for such order changes. |
Sounds good. Let’s move subsequent convo over there |
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
enum { Xx Zz Yy }
union Foo = Xx | Zz | Yy
public struct AsXxOrZzOrYy: GraphQLSelectionSet {
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
EnumTypeDefinition
.Personal recommendation:
enum
s and tagged unions alike areSet
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.The text was updated successfully, but these errors were encountered: