Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/399.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 无法从其他模块或领域使用GraphQLSchema_Javascript_Graphql_Apollo Server_Graphql Js - Fatal编程技术网

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时,另一个重要步骤是重写全局对象(name
schema
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时,另一个重要步骤是重写全局对象(name
schema
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