ChilliCream / graphql-platform

Welcome to the home of the Hot Chocolate GraphQL server for .NET, the Strawberry Shake GraphQL client for .NET and Banana Cake Pop the awesome Monaco based GraphQL IDE.
https://chillicream.com
MIT License
4.96k stars 722 forks source link

Persisted queries in relay format should be written in deterministic order #7075

Closed DanielZuerrer closed 2 weeks ago

DanielZuerrer commented 3 weeks ago

Product

Strawberry Shake

Is your feature request related to a problem?

When writing persisted queries in relay format, the queries are written in non-deterministic order. This leads to changes in the git repository even if the queries remain identical. To fix this, the queries should be written in a deterministic order to file.

The solution you'd like

I already have a proposal for a simple fix: https://github.com/DanielZuerrer/graphql-platform/commit/6c2fd69485553dc8af5e353887e070429b201bb4. I'd be happy to create a pull request if you think the change is sensible.

tobias-tengler commented 3 weeks ago

Sounds like a sensible change to me.

Personally, I'd probably just put the file in a .gitignore and generate the persisted operations during CI. That way you're certain they are up-to-date. Having them checked in doesn't really provide a benefit as they are generated on every build anyways and changes to the operations are already surfaced in code review through the .graphql files.

DanielZuerrer commented 3 weeks ago

I agree that it would probably be the best to not have the persisted queries in version control at all. With our CI setup where solutions are built in docker and pipelines are not setup to extract files from docker images it would require some changing of the pipelines themselves. So I think there is still some value to have the queries be in deterministic order, even if it's probably not the best practice.