[WIP] Fix compiler issue with stale artifacts for Resolvers in watch mode #4415
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Note: This is still a work in progress, and I need to address internal build errors.
The Issue:
When running the compiler in watch mode, the compiler may produce
artifacts for relay resolvers.
For example:
This code would create fragments for the model resolver, including
an identifier, a model instance fragment, etc.
However, a problem arises in watch mode when we rename the type to:
In this case, the old artifacts are not automatically deleted. The issue lies in
the compiler's inability to establish a connection between the resolver
definition code and the artifacts it produces.
To resolve this, we need to establish that connection.
The solution:
The relationship between the source documents (fragments, queries, and now resolvers)
and the generated artifacts is represented in the artifact_map. In this map, the key
corresponds to the document's name (fragment or query), and the value is a
list of the generated artifacts.
For resolvers, we will use the resolver's hash (MD5 of the source) as the key
in the map, and the associated value will be the list of generated artifacts.
The solution involves passing this hash to the artifact generation place
and ensuring the proper handling of the removal of outdated artifacts.