Skip to main content

gqlInterfaceType

Adds a new GraphQL interface to the schema.

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

Options:

  • name

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

  • description

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

@gqlInterfaceType({})
export class ContactItem {
@gqlField({
class: "ContactItem",
type: "ContactLabel",
})
label: ContactLabel;

@gqlField({
class: "ContactItem",
type: GraphQLString,
})
description: string;

constructor(
label: ContactLabel,
description: string,
) {
this.label = label;
this.description = description;
}
}

In this example, we add a new interface type ContactItem which has 2 fields: label, description.