@@ -126,6 +126,8 @@ local result = compiled_query:execute(variables)
126
126
127
127
### Mutations
128
128
129
+ #### Insert
130
+
129
131
Example with an object passed from a variable:
130
132
131
133
```
@@ -180,10 +182,94 @@ Consider the following details:
180
182
* Inserting cannot be used on connection fields, it is allowed only for
181
183
top-level fields (named as well as collections).
182
184
* It is forbidden to use ` insert ` argument with any other argument.
183
- * A mutation with insert argument always return the object that was just
185
+ * A mutation with an ` insert ` argument always return the object that was just
184
186
inserted.
185
187
* Of course ` insert ` argument is forbidden in ` query ` requests.
186
188
189
+ #### Update
190
+
191
+ Example with an update statement passed from a variable. Note that here we
192
+ update an object given by a connection (inside an one of nested fields of a
193
+ request):
194
+
195
+ ```
196
+ mutation update_user_and_order(
197
+ $user_id: String
198
+ $order_id: String
199
+ $xuser: user_collection_update
200
+ $xorder: order_collection_update
201
+ ) {
202
+ # update nested user
203
+ order_collection(order_id: $order_id) {
204
+ order_id
205
+ description
206
+ user_connection(update: $xuser) {
207
+ user_id
208
+ first_name
209
+ last_name
210
+ }
211
+ }
212
+ # update nested order (only the first, because of limit)
213
+ user_collection(user_id: $user_id) {
214
+ user_id
215
+ first_name
216
+ last_name
217
+ order_connection(limit: 1, update: $xorder) {
218
+ order_id
219
+ description
220
+ in_stock
221
+ }
222
+ }
223
+ }
224
+ ```
225
+
226
+ Example with immediate argument for an update statement:
227
+
228
+ ```
229
+ mutation update_user_and_order {
230
+ user_collection(user_id: "user_id_1", update: {
231
+ first_name: "Peter"
232
+ last_name: "Petrov"
233
+ }) {
234
+ user_id
235
+ first_name
236
+ last_name
237
+ }
238
+ order_collection(order_id: "order_id_1", update: {
239
+ description: "Peter's order"
240
+ price: 0.0
241
+ discount: 0.0
242
+ in_stock: false
243
+ }) {
244
+ order_id
245
+ description
246
+ in_stock
247
+ }
248
+ }
249
+ ```
250
+
251
+ Consider the following details:
252
+
253
+ * ` ${collection_name}_update ` is the name of the type whose value intended to
254
+ pass to the ` update ` argument. This type / argument requires a user to set
255
+ subset of fields of an updating object except primary key parts.
256
+ * A mutation with an ` update ` argument always return the updated object.
257
+ * The ` update ` argument is forbidden in ` query ` requests.
258
+ * Objects are selected by filters first, then updated using a statement in the
259
+ ` update ` argument, then connected objects are selected.
260
+ * The ` limit ` and ` offset ` arguments applied before update, so a user can use
261
+ ` limit: 1 ` to update only first match.
262
+ * Objects traversed in deep-first up-first order as it written in a mutation
263
+ request. So an ` update ` argument potentially changes those fields that are
264
+ follows the updated object in this order.
265
+ * Filters by connected objects are performed before update. Resulting connected
266
+ objects given after the update (it is matter when a field(s) of the parent
267
+ objects by whose the connection is made is subject to change).
268
+
269
+ #### Delete
270
+
271
+ TBD
272
+
187
273
## GraphiQL
188
274
```
189
275
local graphql = require('graphql').new({
0 commit comments