keystonejs / keystone

The superpowered headless CMS for Node.js — built with GraphQL and React
https://keystonejs.com
MIT License
9.23k stars 1.16k forks source link

Keystone 16.0.0 Error: Cannot use GraphQLSchema "[object GraphQLSchema]" from another module or realm #3765

Closed devskope closed 3 years ago

devskope commented 4 years ago

Bug report

Describe the bug

I get the following error after bumping @keystonejs/keystone to ^16.0.0:

Error: Cannot use GraphQLSchema "[object GraphQLSchema]" 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/toye/Dev/js/vue/musicx/node_modules/@keystonejs/keystone/node_modules/graphql/jsutils/instanceOf.js:29:13)
    at Object.isSchema (/home/toye/Dev/js/vue/musicx/node_modules/@keystonejs/keystone/node_modules/graphql/type/schema.js:42:34)
    at new ApolloServerBase (/home/toye/Dev/js/vue/musicx/node_modules/@keystonejs/keystone/node_modules/apollo-server-core/dist/ApolloServer.js:160:23)
    at new ApolloServer (/home/toye/Dev/js/vue/musicx/node_modules/@keystonejs/keystone/node_modules/apollo-server-express/dist/ApolloServer.js:60:9)
    at Keystone.createApolloServer (/home/toye/Dev/js/vue/musicx/node_modules/@keystonejs/keystone/lib/Keystone/index.js:453:20)
    at Keystone.prepare (/home/toye/Dev/js/vue/musicx/node_modules/@keystonejs/keystone/lib/Keystone/index.js:615:10)
    at executeDefaultServer (/home/toye/Dev/js/vue/musicx/node_modules/@keystonejs/keystone/bin/utils.js:149:42)

my dependencies:

"dependencies": {
    "@keystonejs/adapter-mongoose": "^9.0.7",
    "@keystonejs/app-admin-ui": "^7.3.6",
    "@keystonejs/app-graphql": "^6.1.2",
    "@keystonejs/app-nuxt": "^5.1.6",
    "@keystonejs/auth-password": "^5.1.14",
    "@keystonejs/fields": "^17.1.3",
    "@keystonejs/fields-cloudinary-image": "^1.0.6",
    "@keystonejs/fields-markdown": "^5.2.9",
    "@keystonejs/fields-wysiwyg-tinymce": "^5.3.10",
    "@keystonejs/file-adapters": "^7.0.7",
    "@keystonejs/keystone": "^16.0.0",
    "@keystonejs/list-plugins": "^7.1.1",
    "@nuxtjs/apollo": "^4.0.1-rc.3",
    "cross-env": "^7.0.2",
    "dotenv": "^8.2.0",
    "express": "^4.17.1",
  },

Deleting ./node_modules/@keystonejs/keystone/node_modules/graphql allows the app to build and start 🤷‍♂️

System information

bookyo commented 4 years ago

in package.json

"resolutions": {
    "graphql": "15.3.0"
  }

can fix this issue.

ralexrdz commented 4 years ago

Dockerfile sugested in documentation will break unless you add a new RUN command to delete graphql inside keystone package

# Runtime container
FROM node:${NODE_VERSION}-alpine

WORKDIR /app

COPY --from=build /app /app

RUN rm -rf node_modules/@keystonejs/keystone/node_modules/graphql

RUN ls dist

CMD ["./dumb-init", "npm", "run", "start"]
jeff-ong commented 3 years ago

yarn dev seems to work fine but any ideas why we can't use npm run dev ?

bladey commented 3 years ago

Keystone 5 has officially moved into active maintenance mode as we push towards the next major new version Keystone Next, you can find out more information about this transition here.

In an effort to sustain the project going forward, we're cleaning up and closing old issues such as this one. If you feel this issue is still relevant for Keystone Next, please let us know.

TkinterinShanghai commented 2 years ago

This issue is still relevant. I just started using keystone for the first time and immediately ran into this error

habdams commented 2 years ago

I am still having this issue as well

dcousens commented 2 years ago

Hi @TkinterinShanghai and @habdams, I think you wanted the issue https://github.com/keystonejs/keystone/issues/7816, not this one :blue_heart:.

I'm will lock this issue in any event, as it isn't actually related to recent versions of keystone-6. If your issue wasn't related to https://github.com/keystonejs/keystone/issues/7816, please open a new GitHub issue.