Stun3R / strapi-generate-types

🖥 CLI to generate types based on your Strapi API content types
MIT License
28 stars 6 forks source link

Error: Duplicate "graphql" modules cannot be used at the same time #61

Open maximelebreton opened 2 years ago

maximelebreton commented 2 years ago

Hello @Stun3R, and thanks for your work.

I have this error when I try to generate types:

Error: Cannot use GraphQLObjectType "Article" 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.

package.json

  "dependencies": {
    "@strapi/plugin-graphql": "4.2.3",
    "@strapi/strapi": "4.2.3",
    "strapi-generate-types": "^0.1.4",
  }

Any ideas how to fix this?

Thanks!

maximelebreton commented 2 years ago

Fixed by modifying the strapi-generate-types/package.json from this:

"dependencies": {
    "@graphql-codegen/core": "1.17.10",
    "@graphql-codegen/typescript": "1.22.3",
    "@graphql-tools/load": "6.2.8",
    "@graphql-tools/url-loader": "6.10.1",
    "@types/fs-extra": "9.0.11",
    "graphql": "15.5.1"

to this:

"dependencies": {
    "@graphql-codegen/core": "^1.17.10",
    "@graphql-codegen/typescript": "^1.22.3",
    "@graphql-tools/load": "^6.2.8",
    "@graphql-tools/url-loader": "^6.10.1",
    "graphql": "^15.5.1",