Prisma 1.9 Duplicate Graphql modules when calling graphql codegen



When trying to generate a typescript file with my prisma graphql types, i get a duplicate module.

Using npm list graphql i found that a nested dependency was dependant on graphql 0.12.3 while the version in the project is 0.13.1.

The error output is:
Error: Cannot use GraphQLNonNull “[Campaign]!” 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.

Package.json is

"dependencies": {
    "apollo-server": "^2.0.0-beta.5",
    "apollo-server-express": "^2.0.0-beta.5",
    "bcryptjs": "2.4.3",
    "express": "^4.16.3",
    "graphql-tag": "^2.9.2",
    "graphql-tools": "^3.0.2",
    "graphql-voyager": "^1.0.0-rc.15",
    "jsonwebtoken": "8.3.0",
    "ts-node": "6.1.1"
  "devDependencies": {
    "@types/bcryptjs": "2.4.1",
    "@types/graphql": "^0.13.1",
    "@types/jest": "^23.0.2",
    "@types/jsonwebtoken": "^7.2.7",
    "@types/node": "10.3.2",
    "dotenv-cli": "1.4.0",
    "graphql-cli": "^2.15.15",
    "jest": "^23.1.0",
    "nodemon": "1.17.5",
    "now": "^11.2.0",
    "npm-run-all": "4.1.3",
    "prettier": "^1.13.2",
    "prisma": "^1.9.0",
    "prisma-binding": "^2.0.2",
    "rimraf": "2.6.2",
    "ts-jest": "^22.4.6",
    "tslint": "^5.10.0",
    "tslint-config-prettier": "^1.13.0",
    "typescript": "^2.9.1"
  "resolutions": {
    "graphql": "0.13.2",
    "graphql-config": "^2.0.0",
    "**/graphql-config": "^2.0.0",
    "**/**/graphql-config": "^2.0.0"

when using this resolutions i get the following from npm list

+-- graphql-cli@2.16.2
| +-- apollo-codegen@0.19.1
| | +-- graphql@0.13.2  deduped
| | `-- graphql-config@1.2.1
| |   `-- graphql@0.12.3
| +-- graphql@0.13.2
| `-- graphql-schema-linter@0.1.1
|   `-- graphql@0.13.2  deduped
`-- prisma@1.9.0
  `-- prisma-cli-core@1.0.46
    `-- graphql@0.13.2  deduped

How do i get only one dependency version on graphql?


What’s the exact command you execute?
Are you using a local or a global npm binary?


I am trying to run it from the projects modules.
I am trying to run yarn graphql codegen command.


codegen was added in graphql-cli@2.16.0, can you see if upgrading graphql-cli in your package.json to the latest version 2.16.2 resolves this problem? :slight_smile:


The initial version which caused the error in the first place was from the newest version. I will however give it another go right away!


I just tried it with the newest version as you specified. And to my absolute horror, it worked.

I have no idea where the errors from above came from. But all is well now i guess.

Thanks for the quick and professional help!


It feels like a mix up of local and global installations, or another “inconsistency” in your npm tree - it’s difficult to say more from a distance :slight_smile: