@pintahub/shopify-api 1.8.2 → 1.8.3
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.
|
@@ -12,28 +12,37 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.UpdateVariant = void 0;
|
|
13
13
|
const ActionBuilder_1 = require("../../ActionBuilder");
|
|
14
14
|
const getGlobalID_1 = require("../../../utils/getGlobalID");
|
|
15
|
+
const handleErrors_1 = require("../../../utils/handleErrors");
|
|
15
16
|
class UpdateVariant extends ActionBuilder_1.ActionBuilder {
|
|
16
17
|
run(args) {
|
|
17
18
|
return __awaiter(this, void 0, void 0, function* () {
|
|
18
|
-
const { id, compareAtPrice } = args;
|
|
19
|
+
const { id, compareAtPrice, price } = args;
|
|
19
20
|
const globalId = (0, getGlobalID_1.getGlobalID)(id, 'ProductVariant');
|
|
21
|
+
const vArgs = Object.assign({}, args, { id: globalId });
|
|
20
22
|
const input = `
|
|
21
23
|
input: {
|
|
22
24
|
id: "${globalId}",
|
|
23
|
-
${compareAtPrice && `compareAtPrice: "${compareAtPrice}"
|
|
25
|
+
${compareAtPrice && `compareAtPrice: "${compareAtPrice}",`}
|
|
26
|
+
${price && `price: "${price}",`}
|
|
24
27
|
}
|
|
25
28
|
`;
|
|
26
29
|
const query = `
|
|
27
|
-
mutation {
|
|
28
|
-
productVariantUpdate($
|
|
30
|
+
mutation productVariantUpdate($input: ProductVariantInput!) {
|
|
31
|
+
productVariantUpdate(input: $input) {
|
|
29
32
|
productVariant {
|
|
30
33
|
id
|
|
31
34
|
compareAtPrice
|
|
35
|
+
price
|
|
32
36
|
}
|
|
33
37
|
}
|
|
34
38
|
}
|
|
35
39
|
`;
|
|
36
|
-
const { data } = yield this.client.request(query
|
|
40
|
+
const { data, errors } = yield this.client.request(query, {
|
|
41
|
+
variables: {
|
|
42
|
+
input: vArgs,
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
yield (0, handleErrors_1.handleErrors)(errors);
|
|
37
46
|
const { productVariantUpdate } = Object.assign({}, data);
|
|
38
47
|
const { productVariant } = Object.assign({}, productVariantUpdate);
|
|
39
48
|
return Object.assign({}, productVariant);
|