-
-
Notifications
You must be signed in to change notification settings - Fork 675
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
Cannot use GraphQLSchema from another module or realm #144
Comments
I got it to work, by explicitly specifying the same version in my package.json as needed by type-graphql. I also had to delete my node_modules and package-lock.json to make npm dedupe the graphql dependency. But I guess it would be better if type-graphql would specify graphql as peerDependency, to prevent such problems. |
It's not so simple. The main problem is that TypeGraphQL is tightly coupled to the version of |
So don't. Just specify the versions you know are compatible at the time of writing. Everyone does it like this. If a new version comes and it is compatible, you can add it later.
I think you need to use it always-even apollo-server-core expects it at as peer dep.
running an apollo server without |
It's not that simple. I even asked Lee Byron for that: And that's what TypeGraphQL does - it's hidding @capaj Could you tell me what will happen when I bump the |
@19majkel94 I think npm exits with a warning telling them they have a mismatched peerDependency. Like for @marciobueno1 : apollographql/apollo-server#291 (comment) |
You are hiding it away, but apollo doesn't. Apollo-server uses |
@capaj It's not an error, only a warning, so it's easy to miss when you have other libs in project, like:
So assuming
No, there are many:
If all ecosystem libraries have all the same semver setup, the only thing you have to do is call |
that's a very big if. Mostly package authors specify their deps quite specific, so it might be impossible to get version of packages which require the right versions of You're definately right about npm-it only warns which is a shame. |
I noticed the same thing and it is plausible too. If I have a dependency it is automatically installed, so usually I would specify a single (mostly the newest) version, but if I have a peer dependency I specify all versions it would work with. |
Peer dependencies makes sense for things like plugins, e.g. https://github.com/19majkel94/class-transformer-validator. But with TypeGraphQL is really tightly coupled to Many packages from ecosystem, like |
The simple fact that So you are building a Edit: |
The simple fact means that npm during install of To demonstrate how npm is deduplicating packages - tak a look at So basically this comes down to this dilemma:
I think that in this situation it's better to cure with dedupe than preventing with peer dependency 😉 |
So this package is meant to work with Your package work with Edit: |
See #140 - it's a major release with breaking changes, so it does't work with with 14.x.x. And no, it works with other packages too. The type error that you receive:
Comes from
As you can see, Peer dependency on |
However there's still an error with As Lee Byron said:
I will come back later to this discussion, depending on how the ecosystem packages will behave. Maybe a section in FAQ about |
I got it to work by removing package.json {
"scripts": {
"postinstall": "rm -rf node_modules/{type-graphql}/node_modules/{@types/graphql,graphql}"
}
} |
@caseyduquettesc Is a temporal Solution, it works for me. |
Temporal messy solution for me: on package.json "resolutions":{
"type-graphql/graphql": "^14.0.2"
},
|
To make it a bit clear for newcomers that are looking for a solution in this issue - there's a little guide in FAQ for this problem: |
Don't know what's happening I have this same problem and only 1 version of graphql resulting from It's even weirder if I tell you it works for the first request and starts having |
@ramonpm TypeGraphQL now comes with |
@19majkel94 could you please suggest me some way to identify the problem? |
fixed now. What helped me was update serverless cli |
I ran into another circumstance which caused this error due to symlinking. I'm using a (kind of) fork of Lerna to manage a project such that my project ended up being structured like this:
even though there is only one actual copy of the graphql library on disk, the module is being loaded by node twice, once when My solution here will be to rewrite a portion of how my Lerna fork works. RIP. |
404 😞 |
I switched from "resolutions": {
"graphql": "^15.3.0"
} It's all working again! 😌 |
In my case, realized I was using graphql v15.x.x in my application package.json while graphql-yoga was using graphql v14.x.x. Deleted the v15.x.x and replaced it with v14.x.x works. That created a single graphql v14.x.x to be used. Hope this helps. |
I work in a monorepo with 2 layers of package.jsons, one on the root and one on project level. My graphql-codegen was using a plugin from the root level, while the graphql-tag was used from the project level, hence two different realms. I fixed it by installing the codegen plugin on project level as well. |
Describe the bug
I installed express-graphql and typed-graphql, then I defined my entities and built the schema, when I pass the Schema to express-graphql and added it to my express app. As soon as I open grahpiql in my browser and run a query I get the error:
Enviorment (please complete the following information):
The text was updated successfully, but these errors were encountered: