Naming Conventions
Consistent naming makes a GraphQL API much easier to learn.
Use clear names for object types:
type User
type Product
type Order
Fields generally use descriptive names:
createdAt
updatedAt
firstName
Arguments should also communicate their purpose:
user(id: ID!)
products(category: ProductCategory)
Mutation names should describe actions:
createUser
updateUser
cancelOrder
publishArticle
Avoid vague mutation names such as:
save
process
execute
handle
unless the domain itself genuinely defines such an operation.
Boolean fields should read naturally:
isActive: Boolean!
hasAccess: Boolean!
canPublish: Boolean!
Consistent naming is especially important in GraphQL because schema exploration tools expose the names directly to developers.
Key Takeaways
- Use descriptive and consistent type names.
- Mutation names should describe business actions.
- Boolean fields should communicate their meaning clearly.
- Schema names become part of the developer experience.
Knowledge Check
Which mutation name most clearly communicates a specific business action?