@gem-sdk/adapter-shopify 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/dist/cjs/api/operations/add-to-cart.js +32 -0
- package/dist/cjs/api/operations/cart-discount-codes-update.js +29 -0
- package/dist/cjs/api/operations/cart-note-update.js +28 -0
- package/dist/cjs/api/operations/create-cart.js +33 -0
- package/dist/cjs/api/operations/get-cart.js +27 -0
- package/dist/cjs/api/operations/remove-cart-item.js +28 -0
- package/dist/cjs/api/operations/update-cart-line.js +34 -0
- package/dist/cjs/graphql/fragments/cart-line.generated.js +54 -0
- package/dist/cjs/graphql/fragments/cart-user-error.generated.js +11 -0
- package/dist/cjs/graphql/fragments/cart.generated.js +46 -0
- package/dist/cjs/graphql/fragments/country.generated.js +14 -0
- package/dist/cjs/graphql/fragments/currency.generated.js +11 -0
- package/dist/cjs/graphql/fragments/image.generated.js +13 -0
- package/dist/cjs/graphql/fragments/money-v2.generated.js +10 -0
- package/dist/cjs/graphql/fragments/product.generated.js +52 -0
- package/dist/cjs/graphql/mutations/cart-create.generated.js +27 -0
- package/dist/cjs/graphql/mutations/cart-discount-codes-update.generated.js +27 -0
- package/dist/cjs/graphql/mutations/cart-lines-add.generated.js +27 -0
- package/dist/cjs/graphql/mutations/cart-lines-remove.generated.js +27 -0
- package/dist/cjs/graphql/mutations/cart-lines-update.generated.js +27 -0
- package/dist/cjs/graphql/mutations/cart-note-update.generated.js +27 -0
- package/dist/cjs/graphql/queries/cart.generated.js +20 -0
- package/dist/cjs/graphql/queries/product.generated.js +13 -0
- package/dist/cjs/graphql/queries/shop-meta.generated.js +21 -0
- package/dist/cjs/helpers/common.js +15 -0
- package/dist/cjs/helpers/normalize.js +58 -0
- package/dist/cjs/index.js +35 -0
- package/dist/esm/api/operations/add-to-cart.js +30 -0
- package/dist/esm/api/operations/cart-discount-codes-update.js +27 -0
- package/dist/esm/api/operations/cart-note-update.js +26 -0
- package/dist/esm/api/operations/create-cart.js +31 -0
- package/dist/esm/api/operations/get-cart.js +25 -0
- package/dist/esm/api/operations/remove-cart-item.js +26 -0
- package/dist/esm/api/operations/update-cart-line.js +32 -0
- package/dist/esm/graphql/fragments/cart-line.generated.js +51 -0
- package/dist/esm/graphql/fragments/cart-user-error.generated.js +9 -0
- package/dist/esm/graphql/fragments/cart.generated.js +44 -0
- package/dist/esm/graphql/fragments/country.generated.js +12 -0
- package/dist/esm/graphql/fragments/currency.generated.js +9 -0
- package/dist/esm/graphql/fragments/image.generated.js +11 -0
- package/dist/esm/graphql/fragments/money-v2.generated.js +8 -0
- package/dist/esm/graphql/fragments/product.generated.js +50 -0
- package/dist/esm/graphql/mutations/cart-create.generated.js +25 -0
- package/dist/esm/graphql/mutations/cart-discount-codes-update.generated.js +25 -0
- package/dist/esm/graphql/mutations/cart-lines-add.generated.js +25 -0
- package/dist/esm/graphql/mutations/cart-lines-remove.generated.js +25 -0
- package/dist/esm/graphql/mutations/cart-lines-update.generated.js +25 -0
- package/dist/esm/graphql/mutations/cart-note-update.generated.js +25 -0
- package/dist/esm/graphql/queries/cart.generated.js +18 -0
- package/dist/esm/graphql/queries/product.generated.js +11 -0
- package/dist/esm/graphql/queries/shop-meta.generated.js +19 -0
- package/dist/esm/helpers/common.js +13 -0
- package/dist/esm/helpers/normalize.js +56 -0
- package/dist/esm/index.js +15 -0
- package/dist/types/index.d.ts +3686 -0
- package/package.json +38 -0
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const composeRequest = (config) => {
|
|
4
|
+
return {
|
|
5
|
+
method: 'POST',
|
|
6
|
+
headers: {
|
|
7
|
+
'Content-Type': 'application/json',
|
|
8
|
+
...(config.storefrontToken
|
|
9
|
+
? { 'X-Shopify-Storefront-Access-Token': config.storefrontToken }
|
|
10
|
+
: {}),
|
|
11
|
+
},
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
exports.composeRequest = composeRequest;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const normalizeCartProductVariant = (variant) => {
|
|
4
|
+
const { compareAtPriceV2, priceV2, weight, weightUnit, id, sku, image } = variant;
|
|
5
|
+
return {
|
|
6
|
+
id,
|
|
7
|
+
requiresShipping: variant.requiresShipping,
|
|
8
|
+
availableForSale: variant.availableForSale,
|
|
9
|
+
sku: sku ?? id,
|
|
10
|
+
name: variant.title,
|
|
11
|
+
listPrice: compareAtPriceV2?.amount ? +compareAtPriceV2?.amount : 0,
|
|
12
|
+
price: +priceV2.amount,
|
|
13
|
+
weight: {
|
|
14
|
+
value: weight ?? 0,
|
|
15
|
+
unit: weightUnit,
|
|
16
|
+
},
|
|
17
|
+
image,
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
const normalizeLineItem = (lineItem) => {
|
|
21
|
+
const { quantity, id, merchandise } = lineItem;
|
|
22
|
+
const variant = normalizeCartProductVariant(merchandise);
|
|
23
|
+
return {
|
|
24
|
+
id,
|
|
25
|
+
quantity,
|
|
26
|
+
variant,
|
|
27
|
+
attributes: lineItem.attributes,
|
|
28
|
+
variantId: variant.id,
|
|
29
|
+
name: variant.name,
|
|
30
|
+
productTitle: merchandise.product.title,
|
|
31
|
+
productId: variant.id,
|
|
32
|
+
path: merchandise.product.handle,
|
|
33
|
+
discounts: [],
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
const normalizeCart = (cart) => {
|
|
37
|
+
const { cost } = cart;
|
|
38
|
+
return {
|
|
39
|
+
createdAt: cart.createdAt,
|
|
40
|
+
id: cart.id,
|
|
41
|
+
lineItems: cart.lines.nodes.map(normalizeLineItem),
|
|
42
|
+
subtotalPrice: +cost.subtotalAmount.amount,
|
|
43
|
+
totalPrice: +cost.totalAmount.amount,
|
|
44
|
+
currency: {
|
|
45
|
+
code: cost.totalAmount.currencyCode,
|
|
46
|
+
},
|
|
47
|
+
taxesIncluded: true,
|
|
48
|
+
lineItemsSubtotalPrice: +cost.subtotalAmount.amount,
|
|
49
|
+
checkoutUrl: cart.checkoutUrl,
|
|
50
|
+
note: cart.note,
|
|
51
|
+
discounts: cart.discountCodes.map((v) => ({
|
|
52
|
+
code: v.code,
|
|
53
|
+
applicable: v.applicable,
|
|
54
|
+
})),
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
exports.normalizeCart = normalizeCart;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var addToCart = require('./api/operations/add-to-cart.js');
|
|
4
|
+
var createCart = require('./api/operations/create-cart.js');
|
|
5
|
+
var getCart = require('./api/operations/get-cart.js');
|
|
6
|
+
var removeCartItem = require('./api/operations/remove-cart-item.js');
|
|
7
|
+
var updateCartLine = require('./api/operations/update-cart-line.js');
|
|
8
|
+
var cartDiscountCodesUpdate = require('./api/operations/cart-discount-codes-update.js');
|
|
9
|
+
var cartNoteUpdate = require('./api/operations/cart-note-update.js');
|
|
10
|
+
var product_generated = require('./graphql/queries/product.generated.js');
|
|
11
|
+
var shopMeta_generated = require('./graphql/queries/shop-meta.generated.js');
|
|
12
|
+
var cartCreate_generated = require('./graphql/mutations/cart-create.generated.js');
|
|
13
|
+
var cartDiscountCodesUpdate_generated = require('./graphql/mutations/cart-discount-codes-update.generated.js');
|
|
14
|
+
var cartLinesAdd_generated = require('./graphql/mutations/cart-lines-add.generated.js');
|
|
15
|
+
var cartLinesRemove_generated = require('./graphql/mutations/cart-lines-remove.generated.js');
|
|
16
|
+
var cartLinesUpdate_generated = require('./graphql/mutations/cart-lines-update.generated.js');
|
|
17
|
+
var cartNoteUpdate_generated = require('./graphql/mutations/cart-note-update.generated.js');
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
exports.addToCartOperation = addToCart.addToCartOperation;
|
|
22
|
+
exports.createCartOperation = createCart.createCartOperation;
|
|
23
|
+
exports.getCartOperation = getCart.getCartOperation;
|
|
24
|
+
exports.removeCartItemOperation = removeCartItem.removeCartItemOperation;
|
|
25
|
+
exports.updateCartLineOperation = updateCartLine.updateCartLineOperation;
|
|
26
|
+
exports.cartDiscountCodesUpdateOperation = cartDiscountCodesUpdate.cartDiscountCodesUpdateOperation;
|
|
27
|
+
exports.cartNoteUpdateOperation = cartNoteUpdate.cartNoteUpdateOperation;
|
|
28
|
+
exports.ProductDocument = product_generated.ProductDocument;
|
|
29
|
+
exports.ShopMetaDocument = shopMeta_generated.ShopMetaDocument;
|
|
30
|
+
exports.CartCreateDocument = cartCreate_generated.CartCreateDocument;
|
|
31
|
+
exports.CartDiscountCodesUpdateDocument = cartDiscountCodesUpdate_generated.CartDiscountCodesUpdateDocument;
|
|
32
|
+
exports.CartLinesAddDocument = cartLinesAdd_generated.CartLinesAddDocument;
|
|
33
|
+
exports.CartLinesRemoveDocument = cartLinesRemove_generated.CartLinesRemoveDocument;
|
|
34
|
+
exports.CartLinesUpdateDocument = cartLinesUpdate_generated.CartLinesUpdateDocument;
|
|
35
|
+
exports.CartNoteUpdateDocument = cartNoteUpdate_generated.CartNoteUpdateDocument;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { CartLinesAddDocument } from '../../graphql/mutations/cart-lines-add.generated.js';
|
|
2
|
+
import { composeRequest } from '../../helpers/common.js';
|
|
3
|
+
import { normalizeCart } from '../../helpers/normalize.js';
|
|
4
|
+
|
|
5
|
+
const addToCartOperation = (config) => {
|
|
6
|
+
const addToCart = async (input) => {
|
|
7
|
+
if (!config.storefrontUrl) {
|
|
8
|
+
throw new Error('Shop is not connected');
|
|
9
|
+
}
|
|
10
|
+
const variables = {
|
|
11
|
+
cartId: input.cartId,
|
|
12
|
+
lines: input.lines.map((v) => ({
|
|
13
|
+
merchandiseId: v.variantId,
|
|
14
|
+
quantity: v.quantity,
|
|
15
|
+
attributes: v.attributes,
|
|
16
|
+
})),
|
|
17
|
+
};
|
|
18
|
+
const res = await fetch(config.storefrontUrl, {
|
|
19
|
+
...composeRequest(config),
|
|
20
|
+
body: JSON.stringify({ query: CartLinesAddDocument, variables }),
|
|
21
|
+
}).then((res) => res.json());
|
|
22
|
+
if (res.data?.cartLinesAdd?.userErrors.length || !res.data?.cartLinesAdd?.cart) {
|
|
23
|
+
throw res.data?.cartLinesAdd?.userErrors;
|
|
24
|
+
}
|
|
25
|
+
return normalizeCart(res.data.cartLinesAdd.cart);
|
|
26
|
+
};
|
|
27
|
+
return addToCart;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export { addToCartOperation };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { CartDiscountCodesUpdateDocument } from '../../graphql/mutations/cart-discount-codes-update.generated.js';
|
|
2
|
+
import { composeRequest } from '../../helpers/common.js';
|
|
3
|
+
import { normalizeCart } from '../../helpers/normalize.js';
|
|
4
|
+
|
|
5
|
+
const cartDiscountCodesUpdateOperation = (config) => {
|
|
6
|
+
const cartNoteUpdate = async (input) => {
|
|
7
|
+
if (!config.storefrontUrl) {
|
|
8
|
+
throw new Error('Shop is not connected');
|
|
9
|
+
}
|
|
10
|
+
const variables = {
|
|
11
|
+
cartId: input.cartId,
|
|
12
|
+
discountCodes: input.discountCodes,
|
|
13
|
+
};
|
|
14
|
+
const res = await fetch(config.storefrontUrl, {
|
|
15
|
+
...composeRequest(config),
|
|
16
|
+
body: JSON.stringify({ query: CartDiscountCodesUpdateDocument, variables }),
|
|
17
|
+
}).then((res) => res.json());
|
|
18
|
+
if (res.data?.cartDiscountCodesUpdate?.userErrors.length ||
|
|
19
|
+
!res.data?.cartDiscountCodesUpdate?.cart) {
|
|
20
|
+
throw res.data?.cartDiscountCodesUpdate?.userErrors;
|
|
21
|
+
}
|
|
22
|
+
return normalizeCart(res.data.cartDiscountCodesUpdate.cart);
|
|
23
|
+
};
|
|
24
|
+
return cartNoteUpdate;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export { cartDiscountCodesUpdateOperation };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { CartNoteUpdateDocument } from '../../graphql/mutations/cart-note-update.generated.js';
|
|
2
|
+
import { composeRequest } from '../../helpers/common.js';
|
|
3
|
+
import { normalizeCart } from '../../helpers/normalize.js';
|
|
4
|
+
|
|
5
|
+
const cartNoteUpdateOperation = (config) => {
|
|
6
|
+
const cartNoteUpdate = async (input) => {
|
|
7
|
+
if (!config.storefrontUrl) {
|
|
8
|
+
throw new Error('Shop is not connected');
|
|
9
|
+
}
|
|
10
|
+
const variables = {
|
|
11
|
+
cartId: input.cartId,
|
|
12
|
+
note: input.note,
|
|
13
|
+
};
|
|
14
|
+
const res = await fetch(config.storefrontUrl, {
|
|
15
|
+
...composeRequest(config),
|
|
16
|
+
body: JSON.stringify({ query: CartNoteUpdateDocument, variables }),
|
|
17
|
+
}).then((res) => res.json());
|
|
18
|
+
if (res.data?.cartNoteUpdate?.userErrors.length || !res.data?.cartNoteUpdate?.cart) {
|
|
19
|
+
throw res.data?.cartNoteUpdate?.userErrors;
|
|
20
|
+
}
|
|
21
|
+
return normalizeCart(res.data.cartNoteUpdate.cart);
|
|
22
|
+
};
|
|
23
|
+
return cartNoteUpdate;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export { cartNoteUpdateOperation };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { CartCreateDocument } from '../../graphql/mutations/cart-create.generated.js';
|
|
2
|
+
import { composeRequest } from '../../helpers/common.js';
|
|
3
|
+
import { normalizeCart } from '../../helpers/normalize.js';
|
|
4
|
+
|
|
5
|
+
const createCartOperation = (config) => {
|
|
6
|
+
const createCart = async (args) => {
|
|
7
|
+
if (!config.storefrontUrl) {
|
|
8
|
+
throw new Error('Shop is not connected');
|
|
9
|
+
}
|
|
10
|
+
const variables = {
|
|
11
|
+
input: {
|
|
12
|
+
lines: args.items.map((v) => ({
|
|
13
|
+
merchandiseId: v.variantId,
|
|
14
|
+
quantity: v.quantity,
|
|
15
|
+
attributes: v.attributes,
|
|
16
|
+
})),
|
|
17
|
+
},
|
|
18
|
+
};
|
|
19
|
+
const res = await fetch(config.storefrontUrl, {
|
|
20
|
+
...composeRequest(config),
|
|
21
|
+
body: JSON.stringify({ query: CartCreateDocument, variables }),
|
|
22
|
+
}).then((res) => res.json());
|
|
23
|
+
if (res.data?.cartCreate?.userErrors.length || !res.data?.cartCreate?.cart) {
|
|
24
|
+
throw res.data?.cartCreate?.userErrors;
|
|
25
|
+
}
|
|
26
|
+
return normalizeCart(res.data.cartCreate.cart);
|
|
27
|
+
};
|
|
28
|
+
return createCart;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export { createCartOperation };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { CartDocument } from '../../graphql/queries/cart.generated.js';
|
|
2
|
+
import { composeRequest } from '../../helpers/common.js';
|
|
3
|
+
import { normalizeCart } from '../../helpers/normalize.js';
|
|
4
|
+
|
|
5
|
+
const getCartOperation = (config) => {
|
|
6
|
+
const getCart = async (input) => {
|
|
7
|
+
if (!config.storefrontUrl) {
|
|
8
|
+
throw new Error('Shop is not connected');
|
|
9
|
+
}
|
|
10
|
+
const variables = {
|
|
11
|
+
id: input.cartId,
|
|
12
|
+
};
|
|
13
|
+
const res = await fetch(config.storefrontUrl, {
|
|
14
|
+
...composeRequest(config),
|
|
15
|
+
body: JSON.stringify({ query: CartDocument, variables }),
|
|
16
|
+
}).then((res) => res.json());
|
|
17
|
+
if (!res.data?.cart) {
|
|
18
|
+
return undefined;
|
|
19
|
+
}
|
|
20
|
+
return normalizeCart(res.data.cart);
|
|
21
|
+
};
|
|
22
|
+
return getCart;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export { getCartOperation };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { CartLinesRemoveDocument } from '../../graphql/mutations/cart-lines-remove.generated.js';
|
|
2
|
+
import { composeRequest } from '../../helpers/common.js';
|
|
3
|
+
import { normalizeCart } from '../../helpers/normalize.js';
|
|
4
|
+
|
|
5
|
+
const removeCartItemOperation = (config) => {
|
|
6
|
+
const removeCartItem = async (input) => {
|
|
7
|
+
if (!config.storefrontUrl) {
|
|
8
|
+
throw new Error('Shop is not connected');
|
|
9
|
+
}
|
|
10
|
+
const variables = {
|
|
11
|
+
cartId: input.cartId,
|
|
12
|
+
lineIds: [input.lineId],
|
|
13
|
+
};
|
|
14
|
+
const res = await fetch(config.storefrontUrl, {
|
|
15
|
+
...composeRequest(config),
|
|
16
|
+
body: JSON.stringify({ query: CartLinesRemoveDocument, variables }),
|
|
17
|
+
}).then((res) => res.json());
|
|
18
|
+
if (res.data?.cartLinesRemove?.userErrors.length || !res.data?.cartLinesRemove?.cart) {
|
|
19
|
+
throw res.data?.cartLinesRemove?.userErrors;
|
|
20
|
+
}
|
|
21
|
+
return normalizeCart(res.data.cartLinesRemove.cart);
|
|
22
|
+
};
|
|
23
|
+
return removeCartItem;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export { removeCartItemOperation };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { CartLinesUpdateDocument } from '../../graphql/mutations/cart-lines-update.generated.js';
|
|
2
|
+
import { composeRequest } from '../../helpers/common.js';
|
|
3
|
+
import { normalizeCart } from '../../helpers/normalize.js';
|
|
4
|
+
|
|
5
|
+
const updateCartLineOperation = (config) => {
|
|
6
|
+
const updateCartLine = async (input) => {
|
|
7
|
+
if (!config.storefrontUrl) {
|
|
8
|
+
throw new Error('Shop is not connected');
|
|
9
|
+
}
|
|
10
|
+
const variables = {
|
|
11
|
+
cartId: input.cartId,
|
|
12
|
+
lines: [
|
|
13
|
+
{
|
|
14
|
+
id: input.line.id,
|
|
15
|
+
merchandiseId: input.line.variantId,
|
|
16
|
+
quantity: input.line.quantity,
|
|
17
|
+
},
|
|
18
|
+
],
|
|
19
|
+
};
|
|
20
|
+
const res = await fetch(config.storefrontUrl, {
|
|
21
|
+
...composeRequest(config),
|
|
22
|
+
body: JSON.stringify({ query: CartLinesUpdateDocument, variables }),
|
|
23
|
+
}).then((res) => res.json());
|
|
24
|
+
if (res.data?.cartLinesUpdate?.userErrors.length || !res.data?.cartLinesUpdate?.cart) {
|
|
25
|
+
throw res.data?.cartLinesUpdate?.userErrors;
|
|
26
|
+
}
|
|
27
|
+
return normalizeCart(res.data?.cartLinesUpdate.cart);
|
|
28
|
+
};
|
|
29
|
+
return updateCartLine;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export { updateCartLineOperation };
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
const CartProductVariantSelect = `
|
|
2
|
+
fragment CartProductVariantSelect on ProductVariant {
|
|
3
|
+
id
|
|
4
|
+
title
|
|
5
|
+
sku
|
|
6
|
+
requiresShipping
|
|
7
|
+
availableForSale
|
|
8
|
+
unitPriceMeasurement {
|
|
9
|
+
measuredType
|
|
10
|
+
quantityUnit
|
|
11
|
+
quantityValue
|
|
12
|
+
}
|
|
13
|
+
priceV2 {
|
|
14
|
+
...MoneyV2Select
|
|
15
|
+
}
|
|
16
|
+
compareAtPriceV2 {
|
|
17
|
+
...MoneyV2Select
|
|
18
|
+
}
|
|
19
|
+
selectedOptions {
|
|
20
|
+
name
|
|
21
|
+
value
|
|
22
|
+
}
|
|
23
|
+
image {
|
|
24
|
+
...ImageSelect
|
|
25
|
+
}
|
|
26
|
+
product {
|
|
27
|
+
id
|
|
28
|
+
handle
|
|
29
|
+
title
|
|
30
|
+
}
|
|
31
|
+
weight
|
|
32
|
+
weightUnit
|
|
33
|
+
}
|
|
34
|
+
`;
|
|
35
|
+
const CartLineSelect = `
|
|
36
|
+
fragment CartLineSelect on CartLine {
|
|
37
|
+
id
|
|
38
|
+
quantity
|
|
39
|
+
attributes {
|
|
40
|
+
key
|
|
41
|
+
value
|
|
42
|
+
}
|
|
43
|
+
merchandise {
|
|
44
|
+
... on ProductVariant {
|
|
45
|
+
...CartProductVariantSelect
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
`;
|
|
50
|
+
|
|
51
|
+
export { CartLineSelect, CartProductVariantSelect };
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
const CartSelect = `
|
|
2
|
+
fragment CartSelect on Cart {
|
|
3
|
+
attributes {
|
|
4
|
+
key
|
|
5
|
+
value
|
|
6
|
+
}
|
|
7
|
+
checkoutUrl
|
|
8
|
+
createdAt
|
|
9
|
+
discountCodes {
|
|
10
|
+
applicable
|
|
11
|
+
code
|
|
12
|
+
}
|
|
13
|
+
cost {
|
|
14
|
+
subtotalAmount {
|
|
15
|
+
...MoneyV2Select
|
|
16
|
+
}
|
|
17
|
+
totalAmount {
|
|
18
|
+
...MoneyV2Select
|
|
19
|
+
}
|
|
20
|
+
totalDutyAmount {
|
|
21
|
+
...MoneyV2Select
|
|
22
|
+
}
|
|
23
|
+
totalTaxAmount {
|
|
24
|
+
...MoneyV2Select
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
id
|
|
28
|
+
lines(first: 250) {
|
|
29
|
+
nodes {
|
|
30
|
+
...CartLineSelect
|
|
31
|
+
}
|
|
32
|
+
pageInfo {
|
|
33
|
+
endCursor
|
|
34
|
+
hasNextPage
|
|
35
|
+
hasPreviousPage
|
|
36
|
+
startCursor
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
note
|
|
40
|
+
updatedAt
|
|
41
|
+
}
|
|
42
|
+
`;
|
|
43
|
+
|
|
44
|
+
export { CartSelect };
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
const ProductSelect = `
|
|
2
|
+
fragment ProductSelect on Product {
|
|
3
|
+
availableForSale
|
|
4
|
+
compareAtPriceRange {
|
|
5
|
+
maxVariantPrice {
|
|
6
|
+
amount
|
|
7
|
+
currencyCode
|
|
8
|
+
}
|
|
9
|
+
minVariantPrice {
|
|
10
|
+
amount
|
|
11
|
+
currencyCode
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
createdAt
|
|
15
|
+
description
|
|
16
|
+
descriptionHtml
|
|
17
|
+
featuredImage {
|
|
18
|
+
altText
|
|
19
|
+
height
|
|
20
|
+
id
|
|
21
|
+
url
|
|
22
|
+
width
|
|
23
|
+
}
|
|
24
|
+
handle
|
|
25
|
+
id
|
|
26
|
+
onlineStoreUrl
|
|
27
|
+
priceRange {
|
|
28
|
+
maxVariantPrice {
|
|
29
|
+
amount
|
|
30
|
+
currencyCode
|
|
31
|
+
}
|
|
32
|
+
minVariantPrice {
|
|
33
|
+
amount
|
|
34
|
+
currencyCode
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
productType
|
|
38
|
+
publishedAt
|
|
39
|
+
seo {
|
|
40
|
+
description
|
|
41
|
+
title
|
|
42
|
+
}
|
|
43
|
+
tags
|
|
44
|
+
title
|
|
45
|
+
totalInventory
|
|
46
|
+
updatedAt
|
|
47
|
+
}
|
|
48
|
+
`;
|
|
49
|
+
|
|
50
|
+
export { ProductSelect };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { CartSelect } from '../fragments/cart.generated.js';
|
|
2
|
+
import { MoneyV2Select } from '../fragments/money-v2.generated.js';
|
|
3
|
+
import { CartLineSelect, CartProductVariantSelect } from '../fragments/cart-line.generated.js';
|
|
4
|
+
import { ImageSelect } from '../fragments/image.generated.js';
|
|
5
|
+
import { CartUserErrorSelect } from '../fragments/cart-user-error.generated.js';
|
|
6
|
+
|
|
7
|
+
const CartCreateDocument = `
|
|
8
|
+
mutation cartCreate($input: CartInput) {
|
|
9
|
+
cartCreate(input: $input) {
|
|
10
|
+
cart {
|
|
11
|
+
...CartSelect
|
|
12
|
+
}
|
|
13
|
+
userErrors {
|
|
14
|
+
...CartUserErrorSelect
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
${CartSelect}
|
|
19
|
+
${MoneyV2Select}
|
|
20
|
+
${CartLineSelect}
|
|
21
|
+
${CartProductVariantSelect}
|
|
22
|
+
${ImageSelect}
|
|
23
|
+
${CartUserErrorSelect}`;
|
|
24
|
+
|
|
25
|
+
export { CartCreateDocument };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { CartSelect } from '../fragments/cart.generated.js';
|
|
2
|
+
import { MoneyV2Select } from '../fragments/money-v2.generated.js';
|
|
3
|
+
import { CartLineSelect, CartProductVariantSelect } from '../fragments/cart-line.generated.js';
|
|
4
|
+
import { ImageSelect } from '../fragments/image.generated.js';
|
|
5
|
+
import { CartUserErrorSelect } from '../fragments/cart-user-error.generated.js';
|
|
6
|
+
|
|
7
|
+
const CartDiscountCodesUpdateDocument = `
|
|
8
|
+
mutation cartDiscountCodesUpdate($cartId: ID!, $discountCodes: [String!]) {
|
|
9
|
+
cartDiscountCodesUpdate(cartId: $cartId, discountCodes: $discountCodes) {
|
|
10
|
+
cart {
|
|
11
|
+
...CartSelect
|
|
12
|
+
}
|
|
13
|
+
userErrors {
|
|
14
|
+
...CartUserErrorSelect
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
${CartSelect}
|
|
19
|
+
${MoneyV2Select}
|
|
20
|
+
${CartLineSelect}
|
|
21
|
+
${CartProductVariantSelect}
|
|
22
|
+
${ImageSelect}
|
|
23
|
+
${CartUserErrorSelect}`;
|
|
24
|
+
|
|
25
|
+
export { CartDiscountCodesUpdateDocument };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { CartSelect } from '../fragments/cart.generated.js';
|
|
2
|
+
import { MoneyV2Select } from '../fragments/money-v2.generated.js';
|
|
3
|
+
import { CartLineSelect, CartProductVariantSelect } from '../fragments/cart-line.generated.js';
|
|
4
|
+
import { ImageSelect } from '../fragments/image.generated.js';
|
|
5
|
+
import { CartUserErrorSelect } from '../fragments/cart-user-error.generated.js';
|
|
6
|
+
|
|
7
|
+
const CartLinesAddDocument = `
|
|
8
|
+
mutation cartLinesAdd($cartId: ID!, $lines: [CartLineInput!]!) {
|
|
9
|
+
cartLinesAdd(cartId: $cartId, lines: $lines) {
|
|
10
|
+
cart {
|
|
11
|
+
...CartSelect
|
|
12
|
+
}
|
|
13
|
+
userErrors {
|
|
14
|
+
...CartUserErrorSelect
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
${CartSelect}
|
|
19
|
+
${MoneyV2Select}
|
|
20
|
+
${CartLineSelect}
|
|
21
|
+
${CartProductVariantSelect}
|
|
22
|
+
${ImageSelect}
|
|
23
|
+
${CartUserErrorSelect}`;
|
|
24
|
+
|
|
25
|
+
export { CartLinesAddDocument };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { CartSelect } from '../fragments/cart.generated.js';
|
|
2
|
+
import { MoneyV2Select } from '../fragments/money-v2.generated.js';
|
|
3
|
+
import { CartLineSelect, CartProductVariantSelect } from '../fragments/cart-line.generated.js';
|
|
4
|
+
import { ImageSelect } from '../fragments/image.generated.js';
|
|
5
|
+
import { CartUserErrorSelect } from '../fragments/cart-user-error.generated.js';
|
|
6
|
+
|
|
7
|
+
const CartLinesRemoveDocument = `
|
|
8
|
+
mutation cartLinesRemove($cartId: ID!, $lineIds: [ID!]!) {
|
|
9
|
+
cartLinesRemove(cartId: $cartId, lineIds: $lineIds) {
|
|
10
|
+
cart {
|
|
11
|
+
...CartSelect
|
|
12
|
+
}
|
|
13
|
+
userErrors {
|
|
14
|
+
...CartUserErrorSelect
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
${CartSelect}
|
|
19
|
+
${MoneyV2Select}
|
|
20
|
+
${CartLineSelect}
|
|
21
|
+
${CartProductVariantSelect}
|
|
22
|
+
${ImageSelect}
|
|
23
|
+
${CartUserErrorSelect}`;
|
|
24
|
+
|
|
25
|
+
export { CartLinesRemoveDocument };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { CartSelect } from '../fragments/cart.generated.js';
|
|
2
|
+
import { MoneyV2Select } from '../fragments/money-v2.generated.js';
|
|
3
|
+
import { CartLineSelect, CartProductVariantSelect } from '../fragments/cart-line.generated.js';
|
|
4
|
+
import { ImageSelect } from '../fragments/image.generated.js';
|
|
5
|
+
import { CartUserErrorSelect } from '../fragments/cart-user-error.generated.js';
|
|
6
|
+
|
|
7
|
+
const CartLinesUpdateDocument = `
|
|
8
|
+
mutation cartLinesUpdate($cartId: ID!, $lines: [CartLineUpdateInput!]!) {
|
|
9
|
+
cartLinesUpdate(cartId: $cartId, lines: $lines) {
|
|
10
|
+
cart {
|
|
11
|
+
...CartSelect
|
|
12
|
+
}
|
|
13
|
+
userErrors {
|
|
14
|
+
...CartUserErrorSelect
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
${CartSelect}
|
|
19
|
+
${MoneyV2Select}
|
|
20
|
+
${CartLineSelect}
|
|
21
|
+
${CartProductVariantSelect}
|
|
22
|
+
${ImageSelect}
|
|
23
|
+
${CartUserErrorSelect}`;
|
|
24
|
+
|
|
25
|
+
export { CartLinesUpdateDocument };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { CartSelect } from '../fragments/cart.generated.js';
|
|
2
|
+
import { MoneyV2Select } from '../fragments/money-v2.generated.js';
|
|
3
|
+
import { CartLineSelect, CartProductVariantSelect } from '../fragments/cart-line.generated.js';
|
|
4
|
+
import { ImageSelect } from '../fragments/image.generated.js';
|
|
5
|
+
import { CartUserErrorSelect } from '../fragments/cart-user-error.generated.js';
|
|
6
|
+
|
|
7
|
+
const CartNoteUpdateDocument = `
|
|
8
|
+
mutation cartNoteUpdate($cartId: ID!, $note: String) {
|
|
9
|
+
cartNoteUpdate(cartId: $cartId, note: $note) {
|
|
10
|
+
cart {
|
|
11
|
+
...CartSelect
|
|
12
|
+
}
|
|
13
|
+
userErrors {
|
|
14
|
+
...CartUserErrorSelect
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
${CartSelect}
|
|
19
|
+
${MoneyV2Select}
|
|
20
|
+
${CartLineSelect}
|
|
21
|
+
${CartProductVariantSelect}
|
|
22
|
+
${ImageSelect}
|
|
23
|
+
${CartUserErrorSelect}`;
|
|
24
|
+
|
|
25
|
+
export { CartNoteUpdateDocument };
|