A guide for building great GraphQL servers and clients.
- Follow the Apollo Schema Naming Conventions document for conventions on naming types, fields, and arguments.
- Avoid accepting overloaded or multiple arguments for a field, ie
donor(id: ID, email: String)
, create multiple fields instead, iefindDonorByID(id: ID!)
andfindDonorByEmail(email: String!)
- Use the GraphQL Dataloader pattern to eager load associations and avoid n + 1 queries. For example, GraphQL Batch.
- Use a single argument called input when creating mutations, following the Relay spec. Example
- Always include a type's ID field if it has one for caching.
- Colocate queries and mutations in the components they are used
- Colocate fragments to split up query logic between components.