I'm using the graphql npm package to build up a graphql schema that includes a mutation that looks like this:
type Mutation {
cxUnitCosts_onSave(data: [CxUnitCostInput]): [CxUnitCost]
}
which I do like this, assuming I have an input and output variables containing GraphQLObjectTypes:
new GraphQLObjectType({
name: 'Mutation',
fields: {
[camelcase(output.toString())+'s_onSave']: {
args: {data: {type: new GraphQLList(input)},
},
type: new GraphQLList(output)
}
}
})
But what I want is to extend the type mutation to produce something like this:
extend type Mutation {
cxUnitCosts_onSave(data: [CxUnitCostInput]): [CxUnitCost]
}
I need to extend Mutation because I am merging together a large number of schema programmatically generated from JSON Schema (many dozens of cxFoo...) If I don't extend the mutation, only one survives the merge.
I would rather not use String manipulation as in the answer below and I would prefer not to have to do the merging manually. I don't want to have to look inside the schema.
For the life of me I can't figure out how.