Skip to main content

gqlUnionType

Adds a new GraphQL Union to the schema.

Until this bug is fixed, custom unions need to be defined in a separate file from where they're consumed.

Options:

  • name

Name of the union type. If not specified, defaults to the name of the class.

  • description

Description of the union. Will be added to the Schema and exposed in tools like GraphiQL or Playground.

  • unionTypes

List of union Types.

@gqlUnionType({
unionTypes: ["ContactEmail", "ContactPhoneNumber", "ContactDate"],
})
export class ContactItemResult {}

In this example, we add a new Union type ContactItemResult which could be one of three types: ContactEmail, ContactPhoneNumber, ContactDate.