启动KeystoneJS应用程序时GraphQL错误

我刚刚用以下方法创建了一个KeystoneJS yarn create keystone-app my-app.

当我尝试用 yarn dev 并浏览到它,我得到以下错误。

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 (/my/home/path/my-first-ks-app/node_modules/@keystonejs/keystone/node_modules/graphql/jsutils/instanceOf.js:28:13)
    at isSchema (/my/home/path/my-first-ks-app/node_modules/@keystonejs/keystone/node_modules/graphql/type/schema.js:36:34)
    at assertSchema (/my/home/path/my-first-ks-app/node_modules/@keystonejs/keystone/node_modules/graphql/type/schema.js:40:8)
    at validateSchema (/my/home/path/my-first-ks-app/node_modules/@keystonejs/keystone/node_modules/graphql/type/validate.js:44:28)
    at graphqlImpl (/my/home/path/my-first-ks-app/node_modules/@keystonejs/keystone/node_modules/graphql/graphql.js:79:62)
    at /my/home/path/my-first-ks-app/node_modules/@keystonejs/keystone/node_modules/graphql/graphql.js:28:59
    at new Promise (<anonymous>)
    at graphql (/my/home/path/my-first-ks-app/node_modules/@keystonejs/keystone/node_modules/graphql/graphql.js:26:10)
    at _graphQLQuery.<computed> (/my/home/path/my-first-ks-app/node_modules/@keystonejs/keystone/lib/Keystone/index.js:477:7)
    at Keystone.executeQuery (/my/home/path/my-first-ks-app/node_modules/@keystonejs/keystone/lib/Keystone/index.js:252:14)
    at Object.module.exports [as onConnect] (/my/home/path/my-first-ks-app/initial-data.js:10:22)
    at /my/home/path/my-first-ks-app/node_modules/@keystonejs/keystone/lib/Keystone/index.js:323:35
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at async executeDefaultServer (/my/home/path/my-first-ks-app/node_modules/@keystonejs/keystone/bin/utils.js:114:3)
error Command failed with exit code 1.

我在Windows 10 WSL(v1)和Ubuntu上。KeystoneJS从Linux运行,MongoDB服务器安装并在Windows上运行。这是因为当我让它在Linux中运行时。mongod 显示为正在运行和监听,但我无法连接到它(通过KeystoneJS或通过shell用 mongo 命令)。)

如何解决这个问题?

解决方案:

我使用的是 graphql@15.0.0 当我得到这个错误的时候。

我把它降级为 graphql@14.6.0.

我在一个使用apollo的keystone项目中遇到了这个问题。

本文来自投稿,不代表运维实战侠立场,如若转载,请注明出处:https://www.shizhanxia.com/775.html

(0)
上一篇 2022年6月29日 下午4:00
下一篇 2022年6月29日 下午4:00

相关推荐

发表评论

登录后才能评论