GraphQL Union and Input Type?

2020-03-01 05:12发布

问题:

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