Skip to content

Commit 62091c7

Browse files
authored
Improve GraphQL examples (#1675)
* Discounts * Permissions * Transactions * Bulks * Export * Taxes
1 parent 31d7e0d commit 62091c7

19 files changed

+1581
-859
lines changed

docs/developer/bulks/bulk-attributes.mdx

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
---
22
title: Bulk Attribute Import
33
---
4+
import Tabs from "@theme/Tabs";
5+
import TabItem from "@theme/TabItem";
46

57
This guide describes a mutation allowing users to create and update multiple attributes in Saleor. The purpose of these mutations could be to import attributes from other systems.
68

@@ -33,6 +35,8 @@ To edit and create attributes, a user needs to have the following permissions, d
3335

3436
### Example Mutation
3537

38+
<Tabs>
39+
<TabItem value="Mutation">
3640
```graphql
3741
mutation AttributeBulkCreate(
3842
$attributes: [AttributeCreateInput!]!
@@ -71,9 +75,8 @@ mutation AttributeBulkCreate(
7175
}
7276
}
7377
```
74-
75-
#### Input example:
76-
78+
</TabItem>
79+
<TabItem value={"Variables"}>
7780
```json
7881
{
7982
"attributes": [
@@ -102,9 +105,8 @@ mutation AttributeBulkCreate(
102105
]
103106
}
104107
```
105-
106-
#### Expected response:
107-
108+
</TabItem>
109+
<TabItem value={"Result"}>
108110
```json
109111
{
110112
"data": {
@@ -178,6 +180,8 @@ mutation AttributeBulkCreate(
178180
}
179181
}
180182
```
183+
</TabItem>
184+
</Tabs>
181185

182186
### Webhooks
183187

@@ -188,7 +192,8 @@ The mutation will emit `ATTRIBUTE_CREATED` event for every successfully created
188192
To update attributes one of the following fields is required: `id` or `externalReference`.
189193

190194
### Example Mutation
191-
195+
<Tabs>
196+
<TabItem value="Mutation">
192197
```graphql
193198
mutation AttributeBulkUpdate(
194199
$attributes: [AttributeBulkUpdateInput!]!
@@ -227,9 +232,8 @@ mutation AttributeBulkUpdate(
227232
}
228233
}
229234
```
230-
231-
#### Input example:
232-
235+
</TabItem>
236+
<TabItem value={"Variables"}>
233237
```json
234238
{
235239
"attributes": [
@@ -254,9 +258,8 @@ mutation AttributeBulkUpdate(
254258
]
255259
}
256260
```
257-
258-
#### Expected response:
259-
261+
</TabItem>
262+
<TabItem value={"Result"}>
260263
```json
261264
{
262265
"data": {
@@ -331,6 +334,9 @@ mutation AttributeBulkUpdate(
331334
}
332335
```
333336

337+
</TabItem>
338+
</Tabs>
339+
334340
### Webhooks
335341

336342
The mutation will emit `ATTRIBUTE_UPDATED` event for every successfully updated attribute or when value is added or removed.

docs/developer/bulks/bulk-orders.mdx

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,18 @@
22
title: Bulk Order Import
33
---
44

5+
6+
import Tabs from "@theme/Tabs";
7+
import TabItem from "@theme/TabItem";
8+
59
This guide describes a mutation allowing users to create multiple orders in Saleor. Purpose of this mutation could be importing orders from other systems. The main assumption is to allow the user to specify as many fields as possible and skip most of the logic and calculations that are done when creating orders from draft or checkout. Among other things, the mutation allows specifying things like: order creation date, order number, order lines with net and gross line prices, payment transactions and fulfillments.
610

711
## `orderBulkCreate`
812

913
### Example Mutation
1014

15+
<Tabs>
16+
<TabItem value="Mutation">
1117
```graphql
1218
mutation OrderBulkCreate(
1319
$orders: [OrderBulkCreateInput!]!
@@ -222,9 +228,9 @@ mutation OrderBulkCreate(
222228
}
223229
}
224230
```
231+
</TabItem>
225232

226-
#### Input example:
227-
233+
<TabItem value={"Variables"}>
228234
```graphql
229235
{
230236
"stockUpdatePolicy": "SKIP",
@@ -398,9 +404,9 @@ mutation OrderBulkCreate(
398404
]
399405
}
400406
```
407+
</TabItem>
401408

402-
#### Expected response:
403-
409+
<TabItem value={"Result"}>
404410
```graphql
405411
{
406412
"data": {
@@ -627,6 +633,8 @@ mutation OrderBulkCreate(
627633
}
628634
}
629635
```
636+
</TabItem>
637+
</Tabs>
630638

631639
### Permission
632640

docs/developer/bulks/bulk-products.mdx

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
title: Bulk Product Import
33
---
44

5+
import Tabs from "@theme/Tabs";
6+
import TabItem from "@theme/TabItem";
7+
58
This guide describes mutations allowing users to create multiple products and variants in Saleor.
69

710
:::info
@@ -29,7 +32,8 @@ The mutation supports creating products with their:
2932
- Variants with their own attributes, stocks, and channel listings
3033

3134
### Example Mutation
32-
35+
<Tabs>
36+
<TabItem value="Mutation">
3337
```graphql
3438
mutation ProductBulkCreate($products: [ProductBulkCreateInput!]!, $errorPolicy: ErrorPolicyEnum) {
3539
productBulkCreate(products: $products, errorPolicy: $errorPolicy) {
@@ -55,9 +59,8 @@ fragment Error on ProductBulkCreateError {
5559
channels
5660
}
5761
```
58-
59-
**Input example:**
60-
62+
</TabItem>
63+
<TabItem value={"Variables"}>
6164
```json
6265
{
6366
"errorPolicy": "REJECT_FAILED_ROWS",
@@ -203,6 +206,8 @@ fragment Error on ProductBulkCreateError {
203206
]
204207
}
205208
```
209+
</TabItem>
210+
</Tabs>
206211

207212
### Input details
208213

@@ -262,7 +267,8 @@ The mutation supports creating variants with their:
262267
- Channel listings and pricing
263268

264269
### Example Mutation
265-
270+
<Tabs>
271+
<TabItem value="Mutation">
266272
```graphql
267273
mutation ProductVariantBulkCreate($variants: [ProductVariantBulkCreateInput!]!, $errorPolicy: ErrorPolicyEnum, $product: ID!) {
268274
productVariantBulkCreate(
@@ -299,9 +305,8 @@ fragment Error on ProductVariantBulkError {
299305
channelListings
300306
}
301307
```
302-
303-
**Input example:**
304-
308+
</TabItem>
309+
<TabItem value={"Variables"}>
305310
```json
306311
{
307312
"product": "UHJvZHVjdDoxOTg=",
@@ -361,6 +366,9 @@ fragment Error on ProductVariantBulkError {
361366
}
362367
```
363368

369+
</TabItem>
370+
</Tabs>
371+
364372
### Input details
365373

366374
For detailed information about all available fields, see the [`ProductVariantBulkCreateInput`](/api-reference/products/inputs/product-variant-bulk-create-input).
@@ -431,7 +439,8 @@ The mutation supports updating variants with their:
431439

432440
### Example Mutation
433441

434-
442+
<Tabs>
443+
<TabItem value="Mutation">
435444
```graphql
436445
mutation ProductVariantBulkUpdate($product: ID!, $variants: [ProductVariantBulkUpdateInput!]!, $errorPolicy: ErrorPolicyEnum) {
437446
productVariantBulkUpdate(
@@ -468,9 +477,8 @@ fragment Error on ProductVariantBulkError {
468477
channelListings
469478
}
470479
```
471-
472-
**Input example:**
473-
480+
</TabItem>
481+
<TabItem value={"Variables"}>
474482
```json
475483
{
476484
"product": "UHJvZHVjdDoxOTg=",
@@ -518,6 +526,9 @@ fragment Error on ProductVariantBulkError {
518526
}
519527
```
520528

529+
</TabItem>
530+
</Tabs>
531+
521532
### Input details
522533

523534
For detailed information about all available fields, see the [`ProductVariantBulkUpdateInput`](/api-reference/products/inputs/product-variant-bulk-update-input).

docs/developer/bulks/bulk-stock.mdx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
---
22
title: Bulk Stock Update
33
---
4+
import Tabs from "@theme/Tabs";
5+
import TabItem from "@theme/TabItem";
46

57
This guide describes mutation allowing users to update stock quantities for multiple product variants in Saleor.
68
The purpose of these mutation could be to synchronize stock levels with external inventory management systems.
@@ -22,7 +24,8 @@ Mutation [`stockBulkUpdate`](/api-reference/products/mutations/stock-bulk-update
2224
- Manage stock across multiple warehouses
2325

2426
### Example Mutation
25-
27+
<Tabs>
28+
<TabItem value="Mutation">
2629
```graphql
2730
mutation StockBulkUpdate($stocks: [StockBulkUpdateInput!]!, $errorPolicy: ErrorPolicyEnum) {
2831
stockBulkUpdate(stocks: $stocks, errorPolicy: $errorPolicy) {
@@ -45,9 +48,8 @@ mutation StockBulkUpdate($stocks: [StockBulkUpdateInput!]!, $errorPolicy: ErrorP
4548
}
4649
}
4750
```
48-
49-
**Input example:**
50-
51+
</TabItem>
52+
<TabItem value={"Variables"}>
5153
```json
5254
{
5355
"errorPolicy": "REJECT_FAILED_ROWS",
@@ -63,6 +65,8 @@ mutation StockBulkUpdate($stocks: [StockBulkUpdateInput!]!, $errorPolicy: ErrorP
6365
}]
6466
}
6567
```
68+
</TabItem>
69+
</Tabs>
6670

6771
### Input details
6872

0 commit comments

Comments
 (0)