问题
Is it possible in GraphQL to have an input type that is also a union?
Something like:
const DynamicInputValueType = new GraphQLUnionType({
name: 'DynamicInputType',
types: [GraphQLString, GraphQLFloat, GraphQLInt]
})
but also able to be used as a input for a mutation?
回答1:
As of September 2017, this is not possible. There is an ongoing discussion around this functionality.
回答2:
There is a npm module. I haven't tested. https://www.npmjs.com/package/graphql-union-input-type
来源:https://stackoverflow.com/questions/45288955/graphql-union-and-input-type