keystone icon indicating copy to clipboard operation
keystone copied to clipboard

After upgrade to 1.0.1: Error: Cannot use GraphQLInputObjectType "IDFilter" from another module or realm.

Open chemicalkosek opened this issue 3 years ago • 4 comments

After upgrading to 1.0.1 such error occurs:

 GraphQL API Starting on http://localhost:3000/api/graphql
Error: Cannot use GraphQLInputObjectType "IDFilter" 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.
    at instanceOf (/home/maciek/Dokumenty/websites/amicus2021/backend/node_modules/@keystone-6/core/node_modules/graphql/jsutils/instanceOf.js:35:13)
    at Object.isInputObjectType (/home/maciek/Dokumenty/websites/amicus2021/backend/node_modules/@keystone-6/core/node_modules/graphql/type/definition.js:174:34)
    at createAdminMeta (/home/maciek/Dokumenty/websites/amicus2021/backend/node_modules/@keystone-6/core/dist/initConfig-2fd803cd.cjs.dev.js:166:43)
    at Object.createSystem (/home/maciek/Dokumenty/websites/amicus2021/backend/node_modules/@keystone-6/core/dist/initConfig-2fd803cd.cjs.dev.js:3085:21)
    at setupInitialKeystone (/home/maciek/Dokumenty/websites/amicus2021/backend/node_modules/@keystone-6/core/scripts/dist/keystone-6-core-scripts.cjs.dev.js:399:18)
    at initKeystone (/home/maciek/Dokumenty/websites/amicus2021/backend/node_modules/@keystone-6/core/scripts/dist/keystone-6-core-scripts.cjs.dev.js:165:41)

Node: v14.15.4

Reverting to 1.0.0 fixes the problem.

chemicalkosek avatar Dec 22 '21 13:12 chemicalkosek

Hi! We've been having trouble reproducing this, but it looks like an issue where something other than keystone has also installed the graphql package.

Seeing your lockfile or and your package.json's dependencies would help us get to the bottom of this.

Noviny avatar Dec 22 '21 23:12 Noviny

And I'm back! I did a little more digging, and verified that @keystone-6/auth, @keystone-6/core, and @keystone-6/fields-document all use graphql, and we updated the graphql dependency of all of these.

If keystone is the only thing installing graphql, upgrading all 3 of these at once should resolve the issue.

If not, see previous message about lockfiles and package.json

Noviny avatar Dec 23 '21 00:12 Noviny

Edit: removing node_modules and package-lock.json fixes it for me. I'll leave it for you to decide whether you still consider this an issue.

Package.json:

{
  "name": "keystone-app",
  "version": "5.0.0",
  "private": true,
  "scripts": {
    "dev": "keystone dev",
    "start": "keystone start",
    "build": "keystone build",
    "postinstall": "keystone postinstall",
    "lint": "eslint .",
    "lint:fix": "eslint . --fix"
  },
  "dependencies": {
    "@keystone-6/auth": "^1.0.1",
    "@keystone-6/core": "^1.0.1",
    "@keystone-6/fields-document": "^1.0.1",
    "dotenv": "^10.0.0",
    "slugify": "^1.6.4"
  },
  "engines": {
    "node": "^14.15 || ^16.13"
  },
  "devDependencies": {
    "@babel/core": "^7.16.5",
    "@babel/eslint-parser": "^7.16.5",
    "@babel/preset-react": "^7.16.5",
    "@types/node": "^16.11.16",
    "@typescript-eslint/eslint-plugin": "^5.8.0",
    "@typescript-eslint/parser": "^5.8.0",
    "eslint": "^8.5.0",
    "eslint-config-airbnb": "^19.0.2",
    "eslint-config-airbnb-typescript": "^16.1.0",
    "eslint-config-prettier": "^8.3.0",
    "eslint-config-wesbos": "^3.0.2",
    "eslint-plugin-html": "^6.2.0",
    "eslint-plugin-import": "^2.25.3",
    "eslint-plugin-jsx-a11y": "^6.5.1",
    "eslint-plugin-prettier": "^4.0.0",
    "eslint-plugin-react": "^7.28.0",
    "eslint-plugin-react-hooks": "^4.3.0",
    "prettier": "^2.5.1",
    "typescript": "^4.5.4"
  }
}

Lock file before removal https://gist.github.com/chemicalkosek/785843943acf909f0ac9a3dcdf8f6fbc

chemicalkosek avatar Dec 23 '21 07:12 chemicalkosek

I have same problem( I try to delete yarn.lock, node_modules but it doesn't work for me

Nikitoring avatar Jan 30 '22 20:01 Nikitoring

This just started happening for me too. package.json and package-lock.json:

https://gist.github.com/jschuur/ef5a00e34e9cea168cb1f01748e127f4

I'm using npm (8.15.1) via nvm (0.39.1) and node 16.16.0. @keystone-6/auth 4.0.1, @keystone-6/core 2.2.0 and @keystone-6/fields-document 4.1.0.

If I rebuild the node_modules folder with yarn with a resolutions declaration the problem goes away, but I'm baffled why it cropped up all of a sudden:

  "resolutions": {
    "graphql": "^15.8.0",
    "**/graphql": "^15.8.0"
  }

Update: Even without the resolutions block, yarn still works fine in the latest release.

jschuur avatar Aug 19 '22 17:08 jschuur

I'm hitting the same issue running an npm init keystone-app npm 8.18 node 16.17 [email protected]

package-lock and debug.log : https://gist.github.com/joshkelly/cf0c3768f910a863b8302f4c003e4137.js

joshkelly avatar Aug 19 '22 22:08 joshkelly

I'm hitting the same issue running an npm init keystone-app npm 8.18 node 16.17 [email protected]

Yeah, this definitely looks like a new issue that is affecting npm users now. I get the same problem when I npx create a fresh skeleton project and then run 'npm install' which triggers the keystone post install.

Sure, the node modules are already installed and ready to go after create-keystone-app, but once I install any new package with npm, I get the duplicate graphql error.

Steps to replicate:

  1. npx create-keystone-app keystone-bug
  2. cd keystone-bug
  3. yarn dev
  4. npm install lodash
  5. yarn dev

Step 3 still works, step 5 gets the error posted at the top of the thread.

I began my project a week ago and it only just happened when the Aug 19th update came out, so it looks like this broke things for npm users.

jschuur avatar Aug 20 '22 08:08 jschuur

@jschuur to clarify, you're saying this is only a problem if you are using npm, and not a problem when using yarn?

dcousens avatar Aug 20 '22 13:08 dcousens

@jschuur to clarify, you're saying this is only a problem if you are using npm, and not a problem when using yarn?

Correct. I can use yarn with my existing project and use yarn with a new project fine, both without locking the graphql version via resolutions.

However, I can't continue to use npm to install new modules, since the August 19th update. That worked before, doesn't now.

jschuur avatar Aug 20 '22 13:08 jschuur

npx create-keystone-app is failing for me on a new project with the same error. yarn create keystone-app works as expected.

mzsigler avatar Aug 20 '22 22:08 mzsigler

@jschuur, @mzsigler @joshkelly and others, please see our technical writeup for this problem in https://github.com/keystonejs/keystone/issues/7816#issuecomment-1221725768

I think I will close this issue for now as it is quite old and any new problems should be addressed separately.

dcousens avatar Aug 22 '22 02:08 dcousens