Duplicate graphql error

I created yesterday the app, with the UI, I created collections, fields, etc", all went fine. I can see the API folder was created and so on.
But today when I try to start the server again,
I get this error:

Error: Cannot use GraphQLInputObjectType “FileInfoInput” 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.

I replaced all instances I have found, to be:
“strapi-plugin-graphql”: {
“version”: “^3.4.5”, …}

But it didn’t help.
Any help appreciated,
Thanks,
Avi.

1 Like

I tried to run a new gridsome blog starter, and I have the same error:
Full error:
Server wasn’t able to start properly.
[2021-01-30T13:10:48.102Z] error Error: Cannot use GraphQLInputObjectType “FileInfoInput” 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.

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.
at instanceOf (/home/user/backend/node_modules/strapi-plugin-graphql/node_modules/graphql/jsutils/instanceOf.js:29:13)
at isInputObjectType (/home/user/backend/node_modules/strapi-plugin-graphql/node_modules/graphql/type/definition.js:174:34)
at printType (/home/user/backend/node_modules/strapi-plugin-graphql/node_modules/graphql/utilities/printSchema.js:147:41)
at /home/user/backend/node_modules/strapi-plugin-graphql/node_modules/graphql/utilities/printSchema.js:59:12
at Array.map ()
at printFilteredSchema (/home/user/backend/node_modules/strapi-plugin-graphql/node_modules/graphql/utilities/printSchema.js:58:13)
at Object.printSchema (/home/user/backend/node_modules/strapi-plugin-graphql/node_modules/graphql/utilities/printSchema.js:40:10)
at Object.generateSchema (/home/user/backend/node_modules/strapi-plugin-graphql/services/schema-generator.js:103:33)
at Object.initialize (/home/user/backend/node_modules/strapi-plugin-graphql/hooks/graphql/index.js:81:9)
at /home/user/backend/node_modules/strapi/lib/hooks/index.js:37:28

Removing this line, allowes to start the server.
But I guess, it should be replaced with the correct version?
“strapi-plugin-graphql”: “3.4.5”,

And by the way,
that is the correct way to install strapi plugin:
npm install @gridsome/source-strapi

and on the plugin object it should be:
use: “@gridsome/source-strapi”,
(A bit different on your docs),
Thanks.

Hi, did you find a solution to use graphql yet? I am having the same problem. Removing the plugin from the package.json does allow me to run strapi but without any graphql support…

Can anyone help?

2 Likes

Based on this bug report, the issue is with NPM ver 7+. The reply to that report said that the guidelines only support up to NPM v6 (which is installed with Node LTS v14). If you have Node LTS v16 like I did, it has NPM v 8.1, which causes the problem. I uninstalled Node 16 and installed v14.18.1 (which installed NPM v 6.14.15), and that resolved the issue for me. You can download Node v 14.18.1 from this site.

4 Likes

Have the same problem. its running good in heroku under production but showing
Error: Cannot use GraphQLObjectType "Query" from another module or realm.
running npm run develop. removed package-lock.json and purged node_modules, downgraded NPM version to v 6.14.15, tried to run npm run strapi uninstall graphql and npm run strapi install graphql.

hey .
thanks a lot man .
I can resolve my problem by your guidance.

Still facing the same issue today.
Using node v18.19.0 and npm v10.2.3