You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We are trying to move from Jest to Vitest but stumbled upon issues with graphql having different versions installed for different 3rd party modules. After a bunch of Google-fu, we found that we could use resolutions to force graphql to have only one installed version as can be seen in the second code block below. We still get the same error though and we can't figure out why.
FAIL src/api/email/tests/index.test.js > @/api/email > Validate queries
Error: Cannot use Source "{ body: "\n mutation sendInviteEmployeeEmails($data: BatchInviteEmployeeEmails!) {\n sendBatchInviteEmployeeEmails(data: $data) {\n ok\n }\n }\n", name: "GraphQL request", locationOffset: { line: 1, column: 1 } }" from another module or realm.
Ensure that there is only one instance of "graphql" in the node_modules
directory. If different versions of "graphql" are the dependencies of other
relied on modules, use "resolutions" to ensure only one version is installed.
https://yarnpkg.com/en/docs/selective-version-resolutions
Duplicate "graphql" modules cannot be used at the same time since different
versions may have different capabilities and behavior. The data from one
version used in the function from another could produce confusing and
spurious results.
❯ instanceOf node_modules/graphql/jsutils/instanceOf.mjs:36:19
❯ isSource node_modules/graphql/language/source.mjs:49:10
❯ new Parser node_modules/graphql/language/parser.mjs:82:23
❯ Module.parse node_modules/graphql/language/parser.mjs:17:18
❯ Module.validateQuery src/tests/helpers.ts:15:17
13| const source = queryDocument.loc?.source;
14| expect_toBeDefined(source);
15| const ast = parse(source);
| ^
16| const errors = validate(schema, ast);
17| const message = errors[0] ? errors[0].message : '';
❯ src/api/email/tests/index.test.js:7:9
=> Found "graphql@16.7.1"
info Has been hoisted to "graphql"
info Reasons this module exists
- Specified in "dependencies"
- Hoisted from "apollo#graphql"
- Hoisted from "get-graphql-schema#graphql"
- Hoisted from "apollo#apollo-language-server#graphql"
info Disk size without dependencies: "2.37MB"
info Disk size with unique dependencies: "2.37MB"
info Disk size with transitive dependencies: "2.37MB"
info Number of shared dependencies: 0
✨ Done in 0.47s.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
We are trying to move from Jest to Vitest but stumbled upon issues with graphql having different versions installed for different 3rd party modules. After a bunch of Google-fu, we found that we could use resolutions to force graphql to have only one installed version as can be seen in the second code block below. We still get the same error though and we can't figure out why.
Beta Was this translation helpful? Give feedback.
All reactions