Created
May 25, 2020 12:46
-
-
Save joeboyscout04/43bc67b1610ead6c3c07df2e950f3664 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
First, we create a cart: | |
``` | |
mutation cartCreate($input: CartCreateMutationInput!) { | |
cartCreate(input: $input) { | |
cart { | |
...cartInfo | |
} | |
clientMutationId | |
status | |
errors { | |
...errorInfo | |
} | |
} | |
} | |
``` | |
Result: | |
``` | |
{ | |
"data": { | |
"cartCreate": { | |
"cart": { | |
"id": "Q2FydC0zNTEwOTM1", | |
"token": "3510935-b4501f072f0cddf9e2de7612cc80dbe4", | |
"buyableQuantity": 0, | |
"cartSellers": { | |
"edges": [] | |
} | |
}, | |
"clientMutationId": "12345", | |
"status": 200, | |
"errors": null | |
} | |
} | |
} | |
``` | |
Then we retrieve the variant `VmFyaWFudC02MTc4OQ==`: | |
``` | |
fragment variantQL on Variant { | |
id | |
displayable | |
label | |
countOnHand | |
externalId | |
infiniteQuantity | |
lowestPriceCents | |
lowestOriginalPriceCents | |
barcode | |
} | |
# Queries all variants for the given IDs. | |
query getVariants($ids: [ID!]!) { | |
nodes(ids: $ids) { | |
...variantQL | |
} | |
} | |
``` | |
The result says that the item is displayable and that there are 118 on hand. | |
``` | |
{ | |
"data": { | |
"nodes": [ | |
{ | |
"id": "VmFyaWFudC02MTc4OQ==", | |
"displayable": true, | |
"label": "6' 6\" / Medium Heavy / Fast / N/A / 12-20lb / 1 pc / N/A", | |
"countOnHand": 118, | |
"externalId": "1398296", | |
"infiniteQuantity": false, | |
"lowestPriceCents": 7995, | |
"lowestOriginalPriceCents": 7995, | |
"barcode": "036282324923" | |
} | |
] | |
} | |
} | |
``` | |
However, trying to add the item to the cart results in an error: | |
``` | |
{ | |
"data": { | |
"cartAddCartItem": { | |
"cart": null, | |
"clientMutationId": "123", | |
"status": 200, | |
"errors": [ | |
{ | |
"field": "out_of_stock", | |
"messages": [ | |
"variant is out of stock" | |
] | |
} | |
] | |
} | |
} | |
} | |
``` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment