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
Vitest + graphql + @graphql-tools/mock causes duplicate graphql error to be thrown #4605
Comments
I had the same issue. Seems to be related to v1 of vitest. Everything is ok in v 0.34.6 |
@markusv i'm using vitest 0.34.6 both in my project and in the code sandbox 🙁 |
This started happening for me after the |
looks like adding this line to the vite config did the trick in vitest 0.34.6 and 1.0.2 resolve: { alias: { graphql: "graphql/index.js" } }, |
This happened for me too. The vite config trick worked, but I'm using yarn workspaces and have a ton of configs to keep updated with this. I'm glad there's a workaround, but any idea why this would happen to begin with? It seems like the config is likely masking a dependency resolution bug either with vitest or graphql. I don't get this issue running the same type of tests with jest or earlier versions of vitest. |
The // This
import { print } from 'graphql/language/printer';
// Now fails with
Error: Failed to resolve import "graphql/language/printer" from "myfile.ts". Does the file exist? I had to also add aliases for all the related imports too (in the right priority order): resolve: {
alias: {
'graphql/language/printer': 'graphql/language/printer.js',
'graphql/language': 'graphql/language/index.js',
graphql: 'graphql/index.js'
},
} |
Describe the bug
When I try to add mocks to a graphql schema I get the following error message:
This is the source code that works perfectly fine with Jest:
Reproduction
https://codesandbox.io/p/devbox/objective-danilo-8qwtnh?file=%2Findex.test.ts%3A13%2C1
System Info
Used Package Manager
yarn
Validations
The text was updated successfully, but these errors were encountered: