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

Fix circular dependency with DocumentTransform import in InMemoryCache #10935

Closed
jerelmiller opened this issue May 31, 2023 · 2 comments
Closed
Assignees
Labels
Milestone

Comments

@jerelmiller
Copy link
Member

jerelmiller commented May 31, 2023

Issue Description

When testing out the first beta release, I tried to run @apollo/client in a CLI environment and it blows up trying to instantiate InMemoryCache. When logging the import, it appears everything from the cache module is set as undefined. Through trial and error, I have narrowed it down to #10509 which introduced the new custom document transform feature.

Re-reviewing that PR, I noted that InMemoryCache imports the DocumentTransform from core, yet core exports modules from cache resulting in a circular dependency. While some bundlers seem to be able to resolve circular dependencies, running this in the CLI environment fails entirely.

Since DocumentTransform is used both by core and by the cache, we should move that module to a neutral location to avoid the circular dependency.

Link to Reproduction

apollographql/apollo-utils#287

Reproduction Steps

Use the new generate-persisted-query-manifest tool and notice that it blows up with the error:

TypeError: core_1.InMemoryCache is not a constructor
    at generatePersistedQueryManifest (/node_modules/@apollo/generate-persisted-query-manifest/dist/index.js:66:16)
@jerelmiller
Copy link
Member Author

jerelmiller commented May 31, 2023

Fixed with #10937

@github-actions
Copy link
Contributor

github-actions bot commented Jul 1, 2023

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
For general questions, we recommend using StackOverflow or our discord server.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 1, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

1 participant