facebook / relay

Relay is a JavaScript framework for building data-driven React applications.
https://relay.dev
MIT License
18.27k stars 1.8k forks source link

`relay-compiler --validate` not working properly with persisted query generation #4665

Open alex-statsig opened 2 months ago

alex-statsig commented 2 months ago

When relay-compiler --validate is run, typically any incorrect or missing artifacts lead to a non-zero exit code and no changes to the filesystem. I use this in a github workflow to ensure that the author ran relay before submitting the PR.

However, with persisted queries, it silently regenerates the file instead, and does not give any error.

I would expect any mismatches to not modify the filesystem, and instead exit with non-zero exit code. Otherwise a PR can corrupt this file without any validation error being flagged.

Additionally if possible, I would like for this comparison to ignore the order of keys in the file, although perhaps thats a separate discussion. My relay scripts sort the persisted queries by query name to minimize merge conflicts from query hashes moving around, so that would trigger an error potentially. Perhaps this should be built-in as a config option for generating the persisted queries file though.