21. 1. Always start with a high-level view of the objects and
their relationships before you deal with specific fields.
2. Never expose implementation details in your API
design.
3. Design your API around the business domain, not the
implementation, user-interface, or legacy APIs.
4. It's easier to add fields than to remove them.
5. Major business-object types should always implement
Node.
22. 6. Group closely-related fields together into subobjects.
7. Always check whether list fields should be paginated or
not.
8. Always use object references instead of ID fields.
9. Choose field names based on what makes sense, not
based on the implementation or what the field is called
in legacy APIs.
10.Use custom scalar types when you're exposing
something with specific semantic value.
23. 11. Use enums for fields which can only take a specific set of values.
12.The API should provide business logic, not just data. Complex
calculations should be done on the server, in one place, not on
the client, in many places.
13.Provide the raw data too, even when there's business logic
around it.
14.Write separate mutations for separate logical actions on a
resource.
15.Mutating relationships is really complicated and not easily
summarized into a snappy rule.
24. 16.When writing separate mutations for relationships, consider
whether it would be useful for the mutations to operate on multiple
elements at once.
17. Prefix mutation names with the object they are mutating for
alphabetical grouping (e.g. use orderCancel instead
of cancelOrder).
18.Only make input fields required if they're actually semantically
required for the mutation to proceed.
19.Use weaker types for inputs (e.g. String instead of Email) when
the format is unambiguous and client-side validation is complex.
This lets the server run all non-trivial validations at once and return
the errors in a single place in a single format, simplifying the client.
25. 20.Use stronger types for inputs (e.g. DateTime instead of String)
when the format may be ambiguous and client-side validation is
simple. This provides clarity and encourages clients to use stricter
input controls (e.g. a date-picker widget instead of a free-text
field).
21. Structure mutation inputs to reduce duplication, even if this
requires relaxing requiredness constraints on certain fields.
22.Mutations should provide user/business-level errors via
a userErrors field on the mutation payload. The top-level query
errors entry is reserved for client and server-level errors.
23.Most payload fields for a mutation should be nullable, unless there
is really a value to return in every possible error case.
46. •Run JavaScript on Cloudflare with Workers - https://
blog.cloudflare.com/cloudflare-workers-unleashed/
•Early Access - http://apollographql.com/edge
Links
47.
48.
49.
50.
51.
52. •GraphQL + Live Queries: 2 Years in Production (Stephen
Wan) - https://github.com/samsarahq/thunder
•GraphQL + Apollo + Vue = Magic - https://apollo-vue-
love.now.sh/
Resource Links