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

Safely require cleanDocument/toSimpleDocument in graphql-mini-transforms #2760

Merged
merged 1 commit into from
Apr 16, 2024

Conversation

ryanwilsonperkin
Copy link
Member

Description

Fixes #2759

The "jest" and "jest-simple" transforms for graphql-mini-transforms use __dirname in order to retrieve the absolute path to the relative file "document.js" when loading the cleanDocument and toSimpleDocument utilities.

As a result, when the path to these files changes, such as when the package is updated under a manager like pnpm, the directory path will be different but the cache key will not change, causing it to try and use the Jest cached version of these files

Since both cleanDocument and toSimpleDocument are exported at the top-level, we should just reference the graphql-mini-transforms package directly in the require statement.

…orms

The "jest" and "jest-simple" transforms for graphql-mini-transforms use
__dirname in order to retrieve the absolute path to the relative file
"document.js" when loading the cleanDocument and toSimpleDocument
utilities.

As a result, when the path to these files changes, such as when the
package is updated under a manager like pnpm, the directory path will be
different but the cache key will not change, causing it to try and
use the Jest cached version of these files

Since both cleanDocument and toSimpleDocument are exported at the
top-level, we should just reference the `graphql-mini-transforms`
package directly in the require statement.
@ryanwilsonperkin
Copy link
Member Author

/snapit

Copy link
Contributor

🫰✨ Thanks @ryanwilsonperkin! Your snapshothas been published to npm.

Test the snapshot by updating your package.json with the newly published version:

"graphql-mini-transforms": "0.0.0-snapshot-20240416154657"

@ryanwilsonperkin
Copy link
Member Author

Confirmed working across node_modules changes

@ryanwilsonperkin ryanwilsonperkin merged commit d839586 into main Apr 16, 2024
9 checks passed
@ryanwilsonperkin ryanwilsonperkin deleted the graphql-mini-transforms-safe-require branch April 16, 2024 15:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

graphql-mini-transforms breaks Jest cache across version changes / directory moves
2 participants