@@ -124,7 +124,67 @@ local compiled_query = graphql_lib.compile(query)
124
124
local result = compiled_query:execute(variables)
125
125
```
126
126
127
- # GraphiQL
127
+ ### Mutations
128
+
129
+ Example with an object passed from a variable:
130
+
131
+ ```
132
+ mutation insert_user_and_order($user: user_collection_insert,
133
+ $order: order_collection_insert) {
134
+ user_collection(insert: $user) {
135
+ user_id
136
+ first_name
137
+ last_name
138
+ }
139
+ order_collection(insert: $order) {
140
+ order_id
141
+ description
142
+ in_stock
143
+ }
144
+ }
145
+ ```
146
+
147
+ Example with immediate argument for an object:
148
+
149
+ ```
150
+ mutation insert_user_and_order {
151
+ user_collection(insert: {
152
+ user_id: "user_id_new_1"
153
+ first_name: "Peter"
154
+ last_name: "Petrov"
155
+ }) {
156
+ user_id
157
+ first_name
158
+ last_name
159
+ }
160
+ order_collection(insert: {
161
+ order_id: "order_id_new_1"
162
+ user_id: "user_id_new_1"
163
+ description: "Peter's order"
164
+ price: 0.0
165
+ discount: 0.0
166
+ # in_stock: true should be set as default value
167
+ }) {
168
+ order_id
169
+ description
170
+ in_stock
171
+ }
172
+ }
173
+ ```
174
+
175
+ Consider the following details:
176
+
177
+ * ` ${collection_name}_insert ` is the name of the type whose value intended to
178
+ pass to the ` insert ` argument. This type / argument requires a user to set
179
+ all fields of an inserting object.
180
+ * Inserting cannot be used on connection fields, it is allowed only for
181
+ top-level fields (named as well as collections).
182
+ * It is forbidden to use ` insert ` argument with any other argument.
183
+ * A mutation with insert argument always return the object that was just
184
+ inserted.
185
+ * Of course ` insert ` argument is forbidden in ` query ` requests.
186
+
187
+ ## GraphiQL
128
188
```
129
189
local graphql = require('graphql').new({
130
190
schemas = schemas,
0 commit comments