Skip to content

Commit 1f3ae06

Browse files
committed
Apply more changes from code review.
1 parent afe1f30 commit 1f3ae06

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/pages/learn/mutations.mdx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,9 @@ mutation UpdateHumanName($id: ID!, $name: String!) {
9191
}
9292
```
9393

94-
This example demonstrates an important distinction from REST. To update a human's properties using a REST API, you would likely send any updated data to a generalized endpoint for that resource using a `PATCH` request. With GraphQL, instead of creating a generic `updateHuman` mutation, you may choose to define more specific mutation fields such as `updateHumanName` that are designed for the task at hand.
94+
## Purpose-built mutations
95+
96+
The previous example demonstrates an important distinction from REST. To update a human's properties using a REST API, you would likely send any updated data to a generalized endpoint for that resource using a `PATCH` request. With GraphQL, instead of simply creating an `updateHuman` mutation, you can define more specific mutation fields such as `updateHumanName`that are designed for the task at hand.
9597

9698
Purpose-built mutation fields can help make a schema more expressive by allowing the input types for field arguments to be Non-Null types (a generic `updateHuman` mutation would likely need to accept many nullable arguments to handle different update scenarios). Defining this requirement in the schema also eliminates the need for other runtime logic to determine that the appropriate values were submitted to perform the client's desired write operation.
9799

@@ -107,7 +109,7 @@ mutation RateFilm($episode: Episode!, $rating: FilmRating!) {
107109
}
108110
```
109111

110-
As a general rule, schemas should be designed to help clients get the data that they need from the GraphQL API, so the fields defined in a schema should be informed by those use cases.
112+
As a general rule, a GraphQL API should be designed to help clients get and modify data in a way that makes sense for them, so the fields defined in a schema should be informed by those use cases.
111113

112114
## Remove existing data
113115

0 commit comments

Comments
 (0)