The builder determines a class’ role from the directory it lives in, relative to the code-API root (<plugin>/src/Api/). Arbitrary nested subdirectories are allowed for organization and do not change the role; e.g. Queries/Reports/GetStatistics.php and Queries/GetStatistics.php are both queries.
| Directory | Role | What it holds |
|---|---|---|
Queries/ |
GraphQL query | Command classes with an execute() method. Name defaults to camelCase of the class name. |
Mutations/ |
GraphQL mutation | Command classes with an execute() method. Rejected over GET. |
Types/ |
Output type | Plain classes whose public properties become fields. |
InputTypes/ |
Input type | Plain classes used as execute() arguments; a field is optional when its type is nullable or it has a default. |
Enums/ |
Enum type | Backed PHP enums. Case names become SCREAMING_SNAKE_CASE. |
Interfaces/ |
Interface | PHP traits marked #[Name]/#[Description]; types use them to implement. |
Scalars/ |
Custom scalar | Classes with static serialize() / parse(). Applied to fields via #[ScalarType]. |
Attributes/ |
Attribute definitions | Custom PHP 8 attributes (authorization, metadata, …). See Attributes. |
Infrastructure/ |
Convention classes | Optional per-plugin ClassResolver, PrincipalResolver, principal class, HttpStatusResolver. See Infrastructure classes. |
| Anything else | Helpers | Mappers, repositories, stores and other plain helpers (e.g. Utils/, or the reference plugin’s Store.php and Authorization/). Not exposed in the schema. |
The pagination building blocks (Connection, Edge, PageInfo, PaginationParams, cursor helpers) are provided by the engine under Automattic\WooCommerce\Api\Pagination and reused, not redefined.
Notes:
#[Ignore] regardless of placement (e.g. a helper that happens to live under a scanned directory).src/Internal/Api/Autogenerated/ (GraphQLQueries/, GraphQLMutations/, GraphQLTypes/{Output,Input,Enums,Interfaces,Scalars,Pagination}/), but you never edit that tree; see Building and staleness checks.