graphql-js - 如果获得超过 1 个模式,Graphql 工具 mergeSchemas 会抛出错误
问题描述
我正在尝试使用 graphql 工具来执行模式拼接。但是,如果我传递多个模式,则会引发 2 个错误。
有时它会抛出
Object.keys(source).forEach(key => {
^
RangeError: Maximum call stack size exceeded
或者
\'use strict';
^
RangeError: Maximum call stack size exceeded
我的架构设置非常简单。我只有 2 个模式国家和城市。那些也有 UUID、JSON 标量类型。
import {
makeExecutableSchema,
mergeSchemas,
} from 'graphql-tools'
import GraphQLUUID from 'graphql-type-uuid'
import GraphQLJSON from 'graphql-type-json'
const countrySchema = makeExecutableSchema({
typeDefs:`
scalar UUID
type Country {
id: UUID!
name: String
}
type Query {
country: Country
}
`,
resolvers: {
UUID: GraphQLUUID,
}
})
const citySchema = makeExecutableSchema({
typeDefs:`
scalar UUID
scalar JSON
type City {
id: UUID!
name: String
coordinates: JSON
}
type Query {
city: City
}
`,
resolvers: {
UUID: GraphQLUUID,
JSON: GraphQLJSON,
}
})
const resolvers = {
Query: {
country: () => ({ id: '2ij29fij390f3j', name: 'Toronto'}),
city: () => ({id: '2ij29fij390f3j11', name: 'Toronto', coordinates: "[]"})
}
}
export const schema = mergeSchemas({
schemas: [ countrySchema, citySchema],
resolvers: resolvers
});
有趣的是,如果我将 countrySchema 或 citySchema 传递给 schemas 数组。有用。但他们都抛出了我上面提到的错误。
请分享你的想法。
解决方案
这似乎是 6.0.0 版本引入的回归graphql-tools
。通过运行将您的版本降低到 5.0.0 npm install graphql-tools@5.0.0
。如果一个 issue 还没有被打开,你可以在 Github 上为这个 bug 打开一个。
推荐阅读
- angular - 如何使用 ant design (NG-Zorro) carousel 每页显示多个项目?
- node.js - Webdriverio TypeError:element.click 不是函数
- c# - 错误 1 'System.IO.File.WriteAllBytes(string, byte[])' 的最佳重载方法匹配有一些无效参数
- excel - 如何从嵌入外部系统的 TreeView 获取节点项目标题?
- c# - 数据网格视图 全选
- sql - 用于在数据库中查找用户的 SQL 查询的性能
- reactjs - TypeError:无法读取 JEST 和酶测试中未定义的属性“子路径”
- php - PHP 致命错误:允许的内存大小为 1073741824 字节已用尽(试图分配 16777216 字节)
- java - Java android EventBus 得到两个相同的事件
- intellij-idea - 在 Intellij 中传递“-parameters”选项