Skip to content
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

[WIP] Fix compiler issue with stale artifacts for Resolvers in watch mode #4415

Closed
wants to merge 2 commits into from

Conversation

alunyov
Copy link
Contributor

@alunyov alunyov commented Aug 22, 2023

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:

/** @RelayResolver MyType */

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:

/** @RelayResolver  MyNewType */ 

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.

@facebook-github-bot
Copy link
Contributor

@alunyov has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Contributor

@alunyov merged this pull request in 15c2715.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants