【发布时间】:2019-03-13 12:15:34
【问题描述】:
我正在使用 graphql npm 包构建一个 graphql 架构,其中包含如下所示的突变:
type Mutation {
cxUnitCosts_onSave(data: [CxUnitCostInput]): [CxUnitCost]
}
我喜欢这样做,假设我有一个包含 GraphQLObjectTypes 的输入和输出变量:
new GraphQLObjectType({
name: 'Mutation',
fields: {
[camelcase(output.toString())+'s_onSave']: {
args: {data: {type: new GraphQLList(input)},
},
type: new GraphQLList(output)
}
}
})
但我想要扩展类型突变以产生如下内容:
extend type Mutation {
cxUnitCosts_onSave(data: [CxUnitCostInput]): [CxUnitCost]
}
我需要扩展 Mutation,因为我正在合并从 JSON Schema 以编程方式生成的大量模式(许多 cxFoo ......)如果我不扩展突变,只有一个在合并中幸存下来。
我宁愿不使用下面答案中的字符串操作,也不想手动进行合并。我不想查看架构内部。
对于我的一生,我无法弄清楚如何。
【问题讨论】:
标签: graphql graphql-js