https://kotlinlang.org logo
Title
t

Tobias Berger

02/21/2022, 10:49 AM
Hi everyone! We just switched from manually written GraphQL schemas to using the Expediagroup schema generator. One thing we noticed is that enums in our generated schema are now sorted alphabetically. Is there some way to avoid this and retain the original order that the enum had in our Kotlin code?
d

Dariusz Kuc

02/21/2022, 3:41 PM
I believe the printing order is controlled by
graphql-java
to ensure consistent schema SDL
afaik GraphQL enums don't have any additional metadata like Java
ordinal
so I don't think you can enforce consistent order outside of alphabetical one
t

Tobias Berger

02/21/2022, 3:44 PM
ok, thanks for the info. One consumer application generated client code from the schema and was relying on that order, so I will see if we can configure something to stay consistent with our old schema or if we just need the client to make an additional request to get the correctly ordered values.
ah, thanks for the hint, I will have a look into that
d

Dariusz Kuc

02/21/2022, 3:45 PM
I don't think we expose the printer options in graphql-kotlin so you might have to overwrite that logic
t

Tobias Berger

02/21/2022, 3:58 PM
Great pointers, thanks a lot!