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

Ensure types are consistently sorted in introspection result #959

Merged

Conversation

jeroenvisser101
Copy link
Contributor

Wanted to get some feedback on how we're sorting these.

The reason for this change is because we have had issues using graphql-code-generator, which would output different order when the order of introspection changed (which happens when recompiling, I think because of how ParallelCompiler might randomize the order in which types are compiled). When considering which library to change, I considered Absinthe to be the best place, since one might expect the order of introspection to define the order of type generation, and that seems like it's generally a good practice.

I chose to add sorting to Absinthe.Schema.types/1 rather than to introspection alone, as I assumed sorting it there would be the most performant (as we're sorting just the keys, not the types themselves), but I can change this behaviour if this is a hot code path or if there are unwanted side effects to this.

I also considered trying to keep the order in which they are defined/imported in the schema, but because maps with > 32 keys are not sorted, this would require additional work.

@binaryseed
Copy link
Contributor

I do think performance is a concern here, those functions are called for example when an introspection query is made. I think this behavior is desirable, but we should probably refactor this so that it's done just once when the schema is generated...

@binaryseed binaryseed changed the base branch from master to sort-types November 27, 2020 19:31
@binaryseed
Copy link
Contributor

Merging this into a working branch to try and get it accomplished w/o the performance penalty

@binaryseed binaryseed marked this pull request as ready for review November 27, 2020 19:31
@binaryseed binaryseed merged commit a4c92eb into absinthe-graphql:sort-types Nov 27, 2020
@binaryseed
Copy link
Contributor

I opened a new PR that extends this... It's not possible to sort these things at compile time since they are stored as maps. I also made sure each item that is a list is sorted...

@jeroenvisser101
Copy link
Contributor Author

@binaryseed awesome, thanks for fixing! Will test this in our app :)

aaronrenner added a commit to Boulevard/absinthe that referenced this pull request Jun 22, 2021
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

Successfully merging this pull request may close these issues.

None yet

2 participants