Provides a GraphQL union input type for graphql-js, enabling mutations to accept polymorphic input via a single field with type discrimination. Version 0.4.0 is the latest stable release; the package has minimal maintenance. It works by wrapping multiple GraphQLInputObjectType definitions and resolving the concrete type based on a key field, a resolveType function, or AST/value inspection. Unlike core GraphQL, which forbids unions/interfaces on input types, this library allows flexible mutation inputs without manual AST traversal, but requires careful handling of typeKey or resolveType to avoid validation errors.
npm install graphql-union-input-typeNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Creates a union input type combining Jedi and Sith input types using the typeKey 'side', then uses it in a GraphQL mutation.
Downgrade graphql to 0.12.x or earlier, or find an alternative library.
Consider upgrading to graphql-js 17+ and using @oneOf instead of this library.
Prefer using typeKey or resolveType with a simple name-to-type mapping for reliability.
Ensure the key field exists in all input object types, and its value matches the type name specified in inputTypes.
Ensure all types in inputTypes are GraphQLInputObjectType instances, not output types.
Include the required typeKey field (e.g., 'side') in the input argument with a string value matching one of the type names.
Make sure resolveType handles all possible names returned from the typeKey field; if inputTypes is used, ensure the key values match the type names.