Company
Date Published
Author
Caleb Meredith
Word count
1631
Language
English
Hacker News points
None

Summary

Designing a good GraphQL API balances utility and convenience with consideration for how the API may evolve in the future. When designing GraphQL mutations, it's essential to consider naming conventions, specificity, input objects, unique payload types, nesting, and more. A well-named mutation should represent a semantic action that can be taken by the user. Mutations should have one input argument, which is an object type with a non-null unique input type. Nesting is beneficial for both inputs and outputs to allow room for future design changes without cluttering existing schema types. Always create custom object types for each mutation and add output fields as needed, resisting the temptation to return only one type directly. By following these principles, you can design an effective GraphQL mutation system that balances utility with flexibility and maintainability.