-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
BUG codegen incorrectly changes order for persisted operations #9925
Comments
10 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Which packages are impacted by your issue?
@graphql-codegen/client-preset
Describe the bug
https://the-guild.dev/graphql/yoga-server/docs/features/persisted-operations
gives the advise to use https://the-guild.dev/graphql/codegen/plugins/presets/preset-client#persisted-documents
to create our persisted operations. the operation then generates a persisted.document.json like so:
{
"b2c3d4e5f6g7h8i9j0a1": "query Hello { hello }",
"kae4fe7f6g7h8i9ej0ag": "mutation echo($msg: String!) { echo(message: $msg) }"
}
however persistedDocument.js is using printExecutableGraphQLDocument: https://www.npmjs.com/package/@graphql-tools/documents
this sorts all operations alphabetically. But this changes the way mutations work and operations should therefore not be sorted alphabetically see docs: https://spec.graphql.org/October2021/#sec-Mutation
Your Example Website or App
https
Steps to Reproduce the Bug or Issue
create an operation that fires multiple mutations in an order that is not alphabetical
generate trusted documents
see that the order of the mutation in persisted.document.json is different than the original mutations order
Expected behavior
As a user, I expect the order of my mutations to be the same as in my .graphql file so that I can ensure the order in which my mutations are beeing fired. But I am seeing that on generation the order changes.
Screenshots or Videos
results in :
expects:
Platform
Codegen Config File
'./libs/x/src/lib/': {
preset: 'client',
documents: ['./libs/x/*.graphql'],
presetConfig: {
persistedDocuments: {
hashAlgorithm: 'sha256'
},
},
},
Additional context
No response
The text was updated successfully, but these errors were encountered: