Skip to main content

Reference: recognized directories

The builder determines a class' role from the directory it lives in, relative to the code-API root (src/Api/ for core, <plugin>/src/Api/ for a plugin). Arbitrary nested subdirectories are allowed for organization and do not change the role; e.g. Queries/Coupons/GetCoupon.php and Queries/GetCoupon.php are both queries.

DirectoryRoleWhat it holds
Queries/GraphQL queryCommand classes with an execute() method. Name defaults to camelCase of the class name.
Mutations/GraphQL mutationCommand classes with an execute() method. Rejected over GET.
Types/Output typePlain classes whose public properties become fields.
InputTypes/Input typePlain classes used as execute() arguments; a field is optional when its type is nullable or it has a default.
Enums/Enum typeBacked PHP enums. Case names become SCREAMING_SNAKE_CASE.
Interfaces/InterfacePHP traits marked #[Name]/#[Description]; types use them to implement.
Scalars/Custom scalarClasses with static serialize() / parse(). Applied to fields via #[ScalarType].
Pagination/Pagination supportConnection, Edge, PageInfo, PaginationParams, cursor helpers (provided by core; reused, not redefined).
Attributes/Attribute definitionsCustom PHP 8 attributes (authorization, metadata, …). See Attributes.
Infrastructure/Convention classesOptional per-plugin ClassResolver, PrincipalResolver, principal class, HttpStatusResolver. See Infrastructure classes.
Utils/HelpersMappers, repositories, and other plain helpers. Not exposed in the schema.

Notes:

  • Classes the builder shouldn't expose can be excluded with #[Ignore] regardless of placement (e.g. a helper that happens to live under a scanned directory).
  • The generated output mirrors these roles under Internal/Api/Autogenerated/ (GraphQLQueries/, GraphQLMutations/, GraphQLTypes/{Output,Input,Enums,Interfaces,Scalars,Pagination}/), but you never edit that tree; see Building and staleness checks.
  • These conventions are identical for core and for plugins.