Javascript 无法从其他模块或领域使用GraphQLSchema
我正在使用Javascript 无法从其他模块或领域使用GraphQLSchema,javascript,graphql,apollo-server,graphql-js,Javascript,Graphql,Apollo Server,Graphql Js,我正在使用类型graphql和apollo服务器lambda构建一个无服务器后端,但在向graphql端点发出大约第三次请求后,我得到了一个错误 Error: Cannot use GraphQLSchema "[object GraphQLSchema]" from another module or realm. Ensure that there is only one instance of "graphql" in the node_modul
类型graphql
和apollo服务器lambda
构建一个无服务器后端,但在向graphql端点发出大约第三次请求后,我得到了一个错误
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.
我已经降级了
type graphql
,因为版本1.0.0
需要graphql@^15.3.0
,而一些其他依赖项需要graphql,我遇到了类似的问题,并在中找到了建议。
npm重复数据消除
为我解决了这个问题。我遇到了类似的问题,并在中找到了建议。
npm重复数据消除
为我解决了这个问题。我终于找到了解决方案。我将阿波罗服务器lambda升级为3.0.0-alpha.3
,并将类型graphql
恢复为^1.0.0
。我还将分辨率升级为“graphql”:“15.3.0”
在lambda中使用类型graphql时,另一个重要步骤是重写全局对象(nameschema
matters)——
if(!global.schema){
global.schema=buildSchemaAsync({
解析程序:[用户解析程序],
验证:false,
});
}
const schema=global.schema;
我终于找到了解决办法。我将阿波罗服务器lambda升级为3.0.0-alpha.3
,并将类型graphql
恢复为^1.0.0
。我还将分辨率升级为“graphql”:“15.3.0”
在lambda中使用类型graphql时,另一个重要步骤是重写全局对象(nameschema
matters)——
if(!global.schema){
global.schema=buildSchemaAsync({
解析程序:[用户解析程序],
验证:false,
});
}
const schema=global.schema;
阿波罗服务器lambda是否也依赖于graphql
版本?是的,阿波罗服务器-core@2.17.0
需要图形QL:“^0.12.0 | | ^0.13.0 | | ^14.0.0”
作为PeerDependency,apollo server lambda是否也依赖于graphql
版本?是的,apollo server-core@2.17.0
要求将“^0.12.0 | | ^0.13.0 | | | ^14.0.0”作为对等项
dives-backend@1.0.0
├─┬ @types/graphql@14.5.0
│ └── graphql@14.7.0 deduped
└── graphql@14.7.0