-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Error: Cannot use GraphQLSchema "[object GraphQLSchema]" from another module or realm. #4637
Comments
While the actual fix should be made by the apollo team, I found that for now the following fix seems to work. You'll need to use the Webpack resolve config and add the following lines to that section of your Webpack config:
Make sure to replace |
Wow! Thank you very much. It worked. But hope it will break anything because migrating from graphql v14 to v15 might impact from graphql server. I already moved to express-graphql because of this. Thanks again! |
I'd recommend that this issue is reopened, we have a workaround but a fix would be better. |
For the record it's also possible to get this error if you're using |
@thekevinbrown I'm facing this issue right now. It's really not easy to fix it with serverless-offline. I tried a lot of workarounds. |
We have since (as far as I know) fixed the peer dep issue, so there shouldn't be peer dep reasons for multiple graphql copies to exist. Webpack does appear to sometimes make multiple copies of |
@omar-dulaimi we're using serverless offline as well. Our setup is:
|
For people still struggling with this, I managed to work around this issue thanks to @Alec2435's comment + adding a key to
This worked for my monorepo structure with yarn workspaces |
I have also encountered this issue in my Apollo Webpack Typescript project, I have discovered the following: The extensions order inside the Webpack configuration seems to have a major influence. This will produce the error:
This will not produce the error:
|
Hey @botre actually nailed it If I put No need for alias - which also worked, but I believe this solution is more elegant Can someone shed light on why the order of extensions matters and what we can do to fix this issue for good? |
Note for 2021 with Serverless Offline, you now need: module.exports = {
service: 'just-for-local-development',
plugins: ['serverless-offline'],
custom: {
'serverless-offline': {
allowCache: true,
},
},
}; in your |
Without the After reading all the details of the graphqljs documentation I found this:
Strange thing is I have another large monorepo project that doesn't have that extension and is using 15.3.0, but it doesn't run into this issue. A bit baffled tbh |
Thanks @thekevinbrown , after days losing hairs, was the only thing that worked here... |
I am using
type-graphql
andapollo-server-express
together. There is no issue for me when running in a development environment. However, once I want to build the apps for production deployment using webpack, there is an error show:I have check type-graphql version and it is using [email protected]. However, the different case with apollo-server-express that still using the libraries that not support version ^15.0.0 such as
graphql-subscriptions
and alsographql-upload
.What is the best solution to fix this? Do we need to wait for dependencies update release?
The text was updated successfully, but these errors were encountered: