Skip to content

Commit a4e775c

Browse files
committed
respond to suggestions
1 parent 9fee55c commit a4e775c

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

site/graphql-js/Tutorial-Mutations.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@ Let's say we have a “message of the day” server, where anyone can update the
1212

1313
```javascript
1414
type Mutation {
15-
setMessage(message: String): Boolean
15+
setMessage(message: String): String
1616
}
1717

1818
type Query {
1919
getMessage: String
2020
}
2121
```
2222

23-
Since `setMessage` doesn't need to return anything useful, we can just return a `Boolean`.
23+
It's often convenient to have a mutation that maps to a database create or update operation, like `setMessage`, return the same thing that the server stored. That way, if you modify the data on the server, the client can learn about those modifications.
2424

2525
Both mutations and queries can be handled by root resolvers, so the root that implements this schema can simply be:
2626

@@ -29,7 +29,7 @@ var fakeDatabase = {};
2929
var root = {
3030
setMessage: function ({message}) {
3131
fakeDatabase.message = message;
32-
return true;
32+
return message;
3333
}
3434
getMessage: function () {
3535
return fakeDatabase.message;
@@ -39,7 +39,7 @@ var root = {
3939

4040
You don't need anything more than this to implement mutations. But in many cases, you will find a number of different mutations that all accept the same input parameters. A common example is that creating an object in a database and updating an object in a database often take the same parameters. To make your schema simpler, you can use “input types” for this, by using the `input` keyword instead of the `type` keyword.
4141

42-
For example, instead of a single message of the day, let's say we have many messages, indexed in a database by an `ID`, and each message has both a `content` string and an `author` string. We want a mutation API both for creating a new message and for updating an old message. We could use the schema:
42+
For example, instead of a single message of the day, let's say we have many messages, indexed in a database by the `id` field, and each message has both a `content` string and an `author` string. We want a mutation API both for creating a new message and for updating an old message. We could use the schema:
4343

4444
```javascript
4545
input MessageInput {

0 commit comments

Comments
 (0)