Open JonathanUsername opened 5 years ago
Just for some context on the difference in initial implementation and the one that landed; some state maintenance will be needed to keep track of artifacts for files that were removed. I.e. we can't simply merge the existing query map with new changes. This was previously achieved by deriving the full query map from all the individual artifacts and having the compiler remove artifacts for removed files.
Yeah, this is a bug in watch mode due to my changes when importing. We’re happy to accept a fix, but note that the fix should simply keep in-memory state about which files to create/update/delete rather than creating files that it has to clean up.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
It seems
--persist-output
overwrites the file with only the queries that were changed when using--watch
. The expected behaviour would be for it to merge the object or at least to output a queryMap.json with all valid queries. This means that if there are no changes, it's overwritten with an empty object.To clarify further, simply running it twice renders the output useless:
Having spoken with @alloy it seems the issue is in the change from how persisted queries were implemented in https://github.com/facebook/relay/pull/2354 and how they went into 2.0.0 in https://github.com/facebook/relay/commit/708f842c30e3cbb709a6b516002529b7de11dfe3
Specifically, by writing out a new map each time, it clobbers the previous output and has no intermediate state.
This feels like an architectural decision so I'm reluctant to propose a solution, but it seems that managing the state so that you can efficiently output a queryMap of all persisted queries is quite important.
If we don't go back to having the many co-located intermediate
.queryMap.json
files, you would at least need a way to force re-evaluation of all queries in --watch mode, so that the full new map is emitted each time.