Skip to content
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

Control the field ordering in graphql schema #3080

Open
yuhanz opened this issue Jul 12, 2024 · 2 comments
Open

Control the field ordering in graphql schema #3080

yuhanz opened this issue Jul 12, 2024 · 2 comments

Comments

@yuhanz
Copy link

yuhanz commented Jul 12, 2024

We found out from apollo-kotlin client that the schema from graphql federation look different when created with serviceList or supergraphSdl file:

  const gateway = new ApolloGateway({
    serviceList: services,
    // supergraphSdl: supergraphStr,

If ApolloGateway is created with serviceList, then the fields in a type are sorted in alphabetical order.
If ApolloGateway is created with supergraphSdl, then the fields in a type are listed as they were ordered in their subgraph.

Since apollo-kotlin compiles DTO classes based on the schema, the reordering causes the constructor signature incompatible when I switch between the two modes, :( while still at the same schema.

Is there some parameter in ApolloGateway to control the behavior of field ordering in a schema? Any command line tool to sort the fields in a graphql schema could help, too.

@duckki
Copy link
Contributor

duckki commented Jul 12, 2024

serviceList has been deprecated. Is there a reason serviceList has to be used?

@yuhanz
Copy link
Author

yuhanz commented Jul 12, 2024

I see. We had an old Java client (apollo-kotlin) built upon a schema from serviceList. We have moved to supergraphSdl and that caused a newly built of the GraphQL client to be incompatible in the Java code. I guess there will be no support of the schema format of serviceList moving forward. (That's also why the app has moved to supergraphSdl) . Just want to note there is a difference between the two schema formats, and wonder if any one else built tools when they encountered the same issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants