Skip to content

Commit

Permalink
Fixed the user query and the indexing in the mutation example.
Browse files Browse the repository at this point in the history
  • Loading branch information
zgrossbart committed Sep 14, 2018
1 parent 9a93b07 commit 4b26766
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 13 deletions.
6 changes: 3 additions & 3 deletions examples/mutation/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ The mutation is the same for all users and it takes query variables to specify t

```javascript
{
"id": 4,
"id": 3,
"name": "Dave"
}
```
Expand All @@ -83,7 +83,7 @@ Our service will return our new user like this:
{
"data": {
"add": {
"id": "4",
"id": "3",
"name": "Dave"
}
}
Expand All @@ -104,6 +104,6 @@ This is a generic delete mutation. Let's use the query variables to delete Dave

```javascript
{
"id": 4
"id": 3
}
```
14 changes: 4 additions & 10 deletions examples/mutation/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@ const users = [];
*/
@type
class User {
@context
context;

@field(ID)
get id() {
return this.data.id;
Expand All @@ -47,17 +44,17 @@ class User {
* our users array.
*/
users.push(new User({
id: 1,
id: 0,
name: 'alice',
}));

users.push(new User({
id: 2,
id: 1,
name: 'bob',
}));

users.push(new User({
id: 3,
id: 2,
name: 'carol',
}));

Expand All @@ -67,13 +64,10 @@ users.push(new User({
*/
@type
class UserQuery {
@context
context;

@field(User)
@description('Get a specific user.')
user(@arg(ID) id) {
return new User(users[id]);
return users[id];
}

@field([User])
Expand Down

0 comments on commit 4b26766

Please sign in to comment.