Skip to main content

Class decorators

Type, Input, Interface, Query, Mutation, and Subscription accept a class directly or can be called with metadata. Their shared options include GraphQL name, description, directives, and explicit field configuration where applicable.
Enum, Union, and Scalar use definitions appropriate to their GraphQL kind but register into the same type registry and compile into the same schema model.

Field

Field works as an annotated attribute descriptor, method decorator, or callable resolver declaration. Supported metadata includes:
  • name, description, deprecated or deprecation_reason
  • type or type_ for explicit GraphQL type control
  • default or default_factory
  • arguments, directives, extensions, and permission_classes

Arguments

Use Arg(...) as a parameter default or Argument(...) with typing.Annotated. Argument metadata supports names, descriptions, deprecation, defaults, and directives.

Custom directives

@Directive registers a directive definition whose arguments come from the class’s type hints. Apply it with AppliedDirective, validated at build time. See Custom directives & visibility.

Field visibility

Field(private=True) keeps a Python attribute off the schema (still readable by resolvers); Field(external=True) marks a field as federation-@external.

Enum customization

enum_value(...) overrides a member’s GraphQL name, description, or deprecation_reason.