You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: typescript-basic/README.md
-36
Original file line number
Diff line number
Diff line change
@@ -99,42 +99,6 @@ Access to the Graphcool API is secured by a secret. This also applies to the int
99
99
100
100
> Note: Currently, no content of the signed JWT is verified. This will be implemented [according to this proposal](https://github.com/graphcool/framework/issues/1365) at a later stage.
101
101
102
-
#### How to add a new resolver?
103
-
Suppose we want to add a custom resolver to delete a post. We can take the following steps:
104
-
105
-
Add a new `delete` field to the Mutation type in `src/schema.graphql`
106
-
```
107
-
type Mutation {
108
-
createDraft(title: String!, text: String): Post
109
-
publish(id: ID!): Post
110
-
delete(id: ID!): Post
111
-
}
112
-
```
113
-
114
-
Add a `delete` resolver to Mutation part of `src/index.js`
115
-
```
116
-
delete(parent, { id }, ctx, info) {
117
-
return ctx.db.mutation.deletePost(
118
-
{
119
-
where: { id }
120
-
},
121
-
info
122
-
);
123
-
}
124
-
```
125
-
126
-
Run `yarn start`
127
-
128
-
Then we can run the following mutation to delete a post:
129
-
130
-
```
131
-
mutation {
132
-
delete(id: "cuid") {
133
-
id
134
-
}
135
-
}
136
-
```
137
-
138
102
## Community
139
103
140
104
Graphcool has a community of thousands of amazing developers and contributors. Welcome, please join us! 👋
0 commit comments