From 78df86136a7e1ef9f4593a8f52502055cc9f6626 Mon Sep 17 00:00:00 2001 From: Isamu Arimoto Date: Fri, 12 Mar 2021 04:41:30 +0900 Subject: [PATCH 01/13] Update Storefront API to version 2021-01 --- docs/config.js.html | 2 +- package.json | 2 +- schema.json | 513 ++++++++++++++++++++++++----------- src/config.js | 2 +- test/client-test.js | 2 +- test/product-helpers-test.js | 2 +- 6 files changed, 366 insertions(+), 157 deletions(-) diff --git a/docs/config.js.html b/docs/config.js.html index 95162f25b..c6206821e 100644 --- a/docs/config.js.html +++ b/docs/config.js.html @@ -85,7 +85,7 @@

Source: config.js

if (attrs.hasOwnProperty('apiVersion')) { this.apiVersion = attrs.apiVersion; } else { - this.apiVersion = '2020-07'; + this.apiVersion = '2021-01'; } if (attrs.hasOwnProperty('source')) { diff --git a/package.json b/package.json index 7794f02a6..0400a7449 100644 --- a/package.json +++ b/package.json @@ -28,7 +28,7 @@ "lint": "eslint --max-warnings 0 -c .eslintrc.json $(yarn run lint:reporter-args 2>&1 >/dev/null) src/ test/", "lint:reporter-args": "test -n \"${CI}\" && >&2 echo -o $CIRCLE_TEST_REPORTS/junit/eslint.xml -f junit", "print-start-message": "wait-on file:.tmp/test/index.html file:.tmp/test/tests.js tcp:35729 tcp:4200 && echo \"\n\n⚡️⚡️⚡️ Good to go at http://localhost:4200 ⚡️⚡️⚡️\"", - "schema:fetch": "graphql-js-schema-fetch --url 'https://graphql.myshopify.com/api/2020-07/graphql' --header 'Authorization: Basic MzUxYzEyMjAxN2QwZjJhOTU3ZDMyYWU3MjhhZDc0OWM=' | jq '.' > schema.json", + "schema:fetch": "graphql-js-schema-fetch --url 'https://graphql.myshopify.com/api/2021-01/graphql' --header 'Authorization: Basic MzUxYzEyMjAxN2QwZjJhOTU3ZDMyYWU3MjhhZDc0OWM=' | jq '.' > schema.json", "minify-umd:optimized": "echo \"/*\n$(cat LICENSE.txt)\n*/\" > index.umd.min.js && babel-minify index.umd.js >> index.umd.min.js", "minify-umd:unoptimized": "echo \"/*\n$(cat LICENSE.txt)\n*/\" > index.unoptimized.umd.min.js && babel-minify index.unoptimized.umd.js >> index.unoptimized.umd.min.js" }, diff --git a/schema.json b/schema.json index db8d620f7..4fff0b537 100644 --- a/schema.json +++ b/schema.json @@ -662,7 +662,7 @@ { "kind": "OBJECT", "name": "ArticleConnection", - "description": null, + "description": "An auto-generated type for paginating through multiple Articles.\n", "fields": [ { "name": "edges", @@ -713,7 +713,7 @@ { "kind": "OBJECT", "name": "ArticleEdge", - "description": null, + "description": "An auto-generated type which holds one Article and a cursor during pagination.\n", "fields": [ { "name": "cursor", @@ -1203,6 +1203,18 @@ "isDeprecated": false, "deprecationReason": null }, + { + "name": "seo", + "description": "The blog's SEO information.", + "args": [], + "type": { + "kind": "OBJECT", + "name": "SEO", + "ofType": null + }, + "isDeprecated": false, + "deprecationReason": null + }, { "name": "title", "description": "The blogs’s title.", @@ -1250,7 +1262,7 @@ { "kind": "OBJECT", "name": "BlogConnection", - "description": null, + "description": "An auto-generated type for paginating through multiple Blogs.\n", "fields": [ { "name": "edges", @@ -1301,7 +1313,7 @@ { "kind": "OBJECT", "name": "BlogEdge", - "description": null, + "description": "An auto-generated type which holds one Blog and a cursor during pagination.\n", "fields": [ { "name": "cursor", @@ -1718,7 +1730,7 @@ }, { "name": "lineItemsSubtotalPrice", - "description": "The sum of all the prices of all the items in the checkout. Taxes, shipping and discounts excluded.", + "description": "The sum of all the prices of all the items in the checkout. Duties, taxes, shipping and discounts excluded.", "args": [], "type": { "kind": "NON_NULL", @@ -1786,7 +1798,7 @@ }, { "name": "paymentDueV2", - "description": "The amount left to be paid. This is equal to the cost of the line items, taxes and shipping minus discounts and gift cards.", + "description": "The amount left to be paid. This is equal to the cost of the line items, duties, taxes and shipping minus discounts and gift cards.", "args": [], "type": { "kind": "NON_NULL", @@ -1898,7 +1910,7 @@ }, { "name": "subtotalPriceV2", - "description": "Price of the checkout before shipping and taxes.", + "description": "Price of the checkout before duties, shipping and taxes.", "args": [], "type": { "kind": "NON_NULL", @@ -1962,7 +1974,7 @@ }, { "name": "totalPriceV2", - "description": "The sum of all the prices of all the items in the checkout, taxes and discounts included.", + "description": "The sum of all the prices of all the items in the checkout, duties, taxes and discounts included.", "args": [], "type": { "kind": "NON_NULL", @@ -3616,7 +3628,7 @@ { "kind": "ENUM", "name": "CheckoutErrorCode", - "description": "Possible error codes that could be returned by a checkout mutation.", + "description": "Possible error codes that could be returned by CheckoutUserError.", "fields": null, "inputFields": null, "interfaces": null, @@ -4284,7 +4296,7 @@ { "kind": "OBJECT", "name": "CheckoutLineItemConnection", - "description": null, + "description": "An auto-generated type for paginating through multiple CheckoutLineItems.\n", "fields": [ { "name": "edges", @@ -4335,7 +4347,7 @@ { "kind": "OBJECT", "name": "CheckoutLineItemEdge", - "description": null, + "description": "An auto-generated type which holds one CheckoutLineItem and a cursor during pagination.\n", "fields": [ { "name": "cursor", @@ -5290,7 +5302,7 @@ { "kind": "OBJECT", "name": "CollectionConnection", - "description": null, + "description": "An auto-generated type for paginating through multiple Collections.\n", "fields": [ { "name": "edges", @@ -5341,7 +5353,7 @@ { "kind": "OBJECT", "name": "CollectionEdge", - "description": null, + "description": "An auto-generated type which holds one Collection and a cursor during pagination.\n", "fields": [ { "name": "cursor", @@ -5554,7 +5566,7 @@ { "kind": "OBJECT", "name": "CommentConnection", - "description": null, + "description": "An auto-generated type for paginating through multiple Comments.\n", "fields": [ { "name": "edges", @@ -5605,7 +5617,7 @@ { "kind": "OBJECT", "name": "CommentEdge", - "description": null, + "description": "An auto-generated type which holds one Comment and a cursor during pagination.\n", "fields": [ { "name": "cursor", @@ -6231,7 +6243,7 @@ }, { "name": "HK", - "description": "Hong Kong SAR China.", + "description": "Hong Kong SAR.", "isDeprecated": false, "deprecationReason": null }, @@ -6417,7 +6429,7 @@ }, { "name": "MO", - "description": "Macao SAR China.", + "description": "Macao SAR.", "isDeprecated": false, "deprecationReason": null }, @@ -7526,12 +7538,6 @@ "isDeprecated": false, "deprecationReason": null }, - { - "name": "BYR", - "description": "Belarusian Ruble (BYR).", - "isDeprecated": true, - "deprecationReason": "`BYR` is deprecated. Use `BYN` available from version `2019-10` onwards instead." - }, { "name": "BZD", "description": "Belize Dollar (BZD).", @@ -7670,12 +7676,6 @@ "isDeprecated": false, "deprecationReason": null }, - { - "name": "DJF", - "description": "Djiboutian Franc (DJF).", - "isDeprecated": false, - "deprecationReason": null - }, { "name": "DOP", "description": "Dominican Peso (DOP).", @@ -7700,12 +7700,6 @@ "isDeprecated": false, "deprecationReason": null }, - { - "name": "FKP", - "description": "Falkland Islands Pounds (FKP).", - "isDeprecated": false, - "deprecationReason": null - }, { "name": "XPF", "description": "CFP Franc (XPF).", @@ -7718,12 +7712,6 @@ "isDeprecated": false, "deprecationReason": null }, - { - "name": "GIP", - "description": "Gibraltar Pounds (GIP).", - "isDeprecated": false, - "deprecationReason": null - }, { "name": "GMD", "description": "Gambian Dalasi (GMD).", @@ -7754,12 +7742,6 @@ "isDeprecated": false, "deprecationReason": null }, - { - "name": "GNF", - "description": "Guinean Franc (GNF).", - "isDeprecated": false, - "deprecationReason": null - }, { "name": "HTG", "description": "Haitian Gourde (HTG).", @@ -7808,12 +7790,6 @@ "isDeprecated": false, "deprecationReason": null }, - { - "name": "IRR", - "description": "Iranian Rial (IRR).", - "isDeprecated": false, - "deprecationReason": null - }, { "name": "IQD", "description": "Iraqi Dinar (IQD).", @@ -7898,12 +7874,6 @@ "isDeprecated": false, "deprecationReason": null }, - { - "name": "LYD", - "description": "Libyan Dinar (LYD).", - "isDeprecated": false, - "deprecationReason": null - }, { "name": "LTL", "description": "Lithuanian Litai (LTL).", @@ -8102,12 +8072,6 @@ "isDeprecated": false, "deprecationReason": null }, - { - "name": "SHP", - "description": "Saint Helena Pounds (SHP).", - "isDeprecated": false, - "deprecationReason": null - }, { "name": "SAR", "description": "Saudi Riyal (SAR).", @@ -8132,12 +8096,6 @@ "isDeprecated": false, "deprecationReason": null }, - { - "name": "SLL", - "description": "Sierra Leonean Leone (SLL).", - "isDeprecated": false, - "deprecationReason": null - }, { "name": "SGD", "description": "Singapore Dollars (SGD).", @@ -8222,24 +8180,12 @@ "isDeprecated": false, "deprecationReason": null }, - { - "name": "TJS", - "description": "Tajikistani Somoni (TJS).", - "isDeprecated": false, - "deprecationReason": null - }, { "name": "TZS", "description": "Tanzanian Shilling (TZS).", "isDeprecated": false, "deprecationReason": null }, - { - "name": "TOP", - "description": "Tongan Pa'anga (TOP).", - "isDeprecated": false, - "deprecationReason": null - }, { "name": "TTD", "description": "Trinidad and Tobago Dollars (TTD).", @@ -8300,12 +8246,6 @@ "isDeprecated": false, "deprecationReason": null }, - { - "name": "VEF", - "description": "Venezuelan Bolivares (VEF).", - "isDeprecated": false, - "deprecationReason": null - }, { "name": "VND", "description": "Vietnamese đồng (VND).", @@ -8329,6 +8269,114 @@ "description": "Zambian Kwacha (ZMW).", "isDeprecated": false, "deprecationReason": null + }, + { + "name": "BYN", + "description": "Belarusian Ruble (BYN).", + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "BYR", + "description": "Belarusian Ruble (BYR).", + "isDeprecated": true, + "deprecationReason": "`BYR` is deprecated. Use `BYN` available from version `2021-01` onwards instead." + }, + { + "name": "DJF", + "description": "Djiboutian Franc (DJF).", + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "ERN", + "description": "Eritrean Nakfa (ERN).", + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "FKP", + "description": "Falkland Islands Pounds (FKP).", + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "GIP", + "description": "Gibraltar Pounds (GIP).", + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "GNF", + "description": "Guinean Franc (GNF).", + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "IRR", + "description": "Iranian Rial (IRR).", + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "KID", + "description": "Kiribati Dollar (KID).", + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "LYD", + "description": "Libyan Dinar (LYD).", + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "MRU", + "description": "Mauritanian Ouguiya (MRU).", + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "SLL", + "description": "Sierra Leonean Leone (SLL).", + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "SHP", + "description": "Saint Helena Pounds (SHP).", + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "SOS", + "description": "Somali Shilling (SOS).", + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "TJS", + "description": "Tajikistani Somoni (TJS).", + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "TOP", + "description": "Tongan Pa'anga (TOP).", + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "VEF", + "description": "Venezuelan Bolivares (VEF).", + "isDeprecated": true, + "deprecationReason": "`VEF` is deprecated. Use `VES` available from version `2020-10` onwards instead." + }, + { + "name": "VES", + "description": "Venezuelan Bolivares (VES).", + "isDeprecated": false, + "deprecationReason": null } ], "possibleTypes": null @@ -9598,7 +9646,7 @@ { "kind": "ENUM", "name": "CustomerErrorCode", - "description": "Possible error codes that could be returned by a customer mutation.", + "description": "Possible error codes that could be returned by CustomerUserError.", "fields": null, "inputFields": null, "interfaces": null, @@ -10405,7 +10453,7 @@ { "kind": "OBJECT", "name": "DiscountApplicationConnection", - "description": null, + "description": "An auto-generated type for paginating through multiple DiscountApplications.\n", "fields": [ { "name": "edges", @@ -10456,7 +10504,7 @@ { "kind": "OBJECT", "name": "DiscountApplicationEdge", - "description": null, + "description": "An auto-generated type which holds one DiscountApplication and a cursor during pagination.\n", "fields": [ { "name": "cursor", @@ -11058,7 +11106,7 @@ { "kind": "OBJECT", "name": "FulfillmentLineItemConnection", - "description": null, + "description": "An auto-generated type for paginating through multiple FulfillmentLineItems.\n", "fields": [ { "name": "edges", @@ -11109,7 +11157,7 @@ { "kind": "OBJECT", "name": "FulfillmentLineItemEdge", - "description": null, + "description": "An auto-generated type which holds one FulfillmentLineItem and a cursor during pagination.\n", "fields": [ { "name": "cursor", @@ -11361,6 +11409,18 @@ "isDeprecated": false, "deprecationReason": null }, + { + "name": "height", + "description": "The original height of the image in pixels. Returns `null` if the image is not hosted by Shopify.", + "args": [], + "type": { + "kind": "SCALAR", + "name": "Int", + "ofType": null + }, + "isDeprecated": false, + "deprecationReason": null + }, { "name": "id", "description": "A unique identifier for the image.", @@ -11471,6 +11531,18 @@ }, "isDeprecated": false, "deprecationReason": null + }, + { + "name": "width", + "description": "The original width of the image in pixels. Returns `null` if the image is not hosted by Shopify.", + "args": [], + "type": { + "kind": "SCALAR", + "name": "Int", + "ofType": null + }, + "isDeprecated": false, + "deprecationReason": null } ], "inputFields": null, @@ -11481,7 +11553,7 @@ { "kind": "OBJECT", "name": "ImageConnection", - "description": null, + "description": "An auto-generated type for paginating through multiple Images.\n", "fields": [ { "name": "edges", @@ -11561,7 +11633,7 @@ { "kind": "OBJECT", "name": "ImageEdge", - "description": null, + "description": "An auto-generated type which holds one Image and a cursor during pagination.\n", "fields": [ { "name": "cursor", @@ -11896,7 +11968,7 @@ { "kind": "OBJECT", "name": "MailingAddressConnection", - "description": null, + "description": "An auto-generated type for paginating through multiple MailingAddresses.\n", "fields": [ { "name": "edges", @@ -11947,7 +12019,7 @@ { "kind": "OBJECT", "name": "MailingAddressEdge", - "description": null, + "description": "An auto-generated type which holds one MailingAddress and a cursor during pagination.\n", "fields": [ { "name": "cursor", @@ -12282,7 +12354,7 @@ { "kind": "OBJECT", "name": "MediaConnection", - "description": null, + "description": "An auto-generated type for paginating through multiple Media.\n", "fields": [ { "name": "edges", @@ -12368,7 +12440,7 @@ { "kind": "OBJECT", "name": "MediaEdge", - "description": null, + "description": "An auto-generated type which holds one Media and a cursor during pagination.\n", "fields": [ { "name": "cursor", @@ -12658,7 +12730,7 @@ { "kind": "OBJECT", "name": "MetafieldConnection", - "description": null, + "description": "An auto-generated type for paginating through multiple Metafields.\n", "fields": [ { "name": "edges", @@ -12709,7 +12781,7 @@ { "kind": "OBJECT", "name": "MetafieldEdge", - "description": null, + "description": "An auto-generated type which holds one Metafield and a cursor during pagination.\n", "fields": [ { "name": "cursor", @@ -13071,7 +13143,7 @@ { "kind": "OBJECT", "name": "MoneyV2Connection", - "description": null, + "description": "An auto-generated type for paginating through multiple MoneyV2s.\n", "fields": [ { "name": "edges", @@ -13122,7 +13194,7 @@ { "kind": "OBJECT", "name": "MoneyV2Edge", - "description": null, + "description": "An auto-generated type which holds one MoneyV2 and a cursor during pagination.\n", "fields": [ { "name": "cursor", @@ -14053,8 +14125,8 @@ "name": "CheckoutLineItemsAddPayload", "ofType": null }, - "isDeprecated": true, - "deprecationReason": "Use `checkoutLineItemsReplace` instead" + "isDeprecated": false, + "deprecationReason": null }, { "name": "checkoutLineItemsRemove", @@ -14102,8 +14174,8 @@ "name": "CheckoutLineItemsRemovePayload", "ofType": null }, - "isDeprecated": true, - "deprecationReason": "Use `checkoutLineItemsReplace` instead" + "isDeprecated": false, + "deprecationReason": null }, { "name": "checkoutLineItemsReplace", @@ -14200,8 +14272,8 @@ "name": "CheckoutLineItemsUpdatePayload", "ofType": null }, - "isDeprecated": true, - "deprecationReason": "Use `checkoutLineItemsReplace` instead" + "isDeprecated": false, + "deprecationReason": null }, { "name": "checkoutShippingAddressUpdate", @@ -15012,7 +15084,7 @@ "fields": [ { "name": "cancelReason", - "description": "Represents the reason for the order's cancellation. Returns null if the order wasn't canceled.", + "description": "The reason for the order's cancellation. Returns `null` if the order wasn't canceled.", "args": [], "type": { "kind": "ENUM", @@ -15052,7 +15124,7 @@ }, { "name": "currentSubtotalPrice", - "description": "The subtotal of line items and their discounts, excluding line items that have been removed. Does not contain order-level discounts, shipping costs, or shipping discounts. Taxes are not included unless the order is a taxes-included order.", + "description": "The subtotal of line items and their discounts, excluding line items that have been removed. Does not contain order-level discounts, duties, shipping costs, or shipping discounts. Taxes are not included unless the order is a taxes-included order.", "args": [], "type": { "kind": "NON_NULL", @@ -15068,7 +15140,7 @@ }, { "name": "currentTotalPrice", - "description": "The total amount of the order, including taxes and discounts, minus amounts for line items that have been removed.", + "description": "The total amount of the order, including duties, taxes and discounts, minus amounts for line items that have been removed.", "args": [], "type": { "kind": "NON_NULL", @@ -15470,7 +15542,7 @@ }, { "name": "subtotalPriceV2", - "description": "Price of the order before shipping and taxes.", + "description": "Price of the order before duties, shipping and taxes.", "args": [], "type": { "kind": "OBJECT", @@ -15529,7 +15601,7 @@ }, { "name": "totalPriceV2", - "description": "The sum of all the prices of all the items in the order, taxes and discounts included (must be positive).", + "description": "The sum of all the prices of all the items in the order, duties, taxes and discounts included (must be positive).", "args": [], "type": { "kind": "NON_NULL", @@ -15687,7 +15759,7 @@ { "kind": "OBJECT", "name": "OrderConnection", - "description": null, + "description": "An auto-generated type for paginating through multiple Orders.\n", "fields": [ { "name": "edges", @@ -15738,7 +15810,7 @@ { "kind": "OBJECT", "name": "OrderEdge", - "description": null, + "description": "An auto-generated type which holds one Order and a cursor during pagination.\n", "fields": [ { "name": "cursor", @@ -15880,6 +15952,12 @@ "description": "Displayed as **In progress**.", "isDeprecated": false, "deprecationReason": null + }, + { + "name": "SCHEDULED", + "description": "Displayed as **Scheduled**.", + "isDeprecated": false, + "deprecationReason": null } ], "possibleTypes": null @@ -16038,7 +16116,7 @@ { "kind": "OBJECT", "name": "OrderLineItemConnection", - "description": null, + "description": "An auto-generated type for paginating through multiple OrderLineItems.\n", "fields": [ { "name": "edges", @@ -16089,7 +16167,7 @@ { "kind": "OBJECT", "name": "OrderLineItemEdge", - "description": null, + "description": "An auto-generated type which holds one OrderLineItem and a cursor during pagination.\n", "fields": [ { "name": "cursor", @@ -16249,6 +16327,18 @@ "isDeprecated": false, "deprecationReason": null }, + { + "name": "seo", + "description": "The page's SEO information.", + "args": [], + "type": { + "kind": "OBJECT", + "name": "SEO", + "ofType": null + }, + "isDeprecated": false, + "deprecationReason": null + }, { "name": "title", "description": "The title of the page.", @@ -16312,7 +16402,7 @@ { "kind": "OBJECT", "name": "PageConnection", - "description": null, + "description": "An auto-generated type for paginating through multiple Pages.\n", "fields": [ { "name": "edges", @@ -16363,7 +16453,7 @@ { "kind": "OBJECT", "name": "PageEdge", - "description": null, + "description": "An auto-generated type which holds one Page and a cursor during pagination.\n", "fields": [ { "name": "cursor", @@ -17257,6 +17347,16 @@ "ofType": null }, "defaultValue": "false" + }, + { + "name": "sortKey", + "description": "Sort the underlying list by the given key.", + "type": { + "kind": "ENUM", + "name": "ProductMediaSortKeys", + "ofType": null + }, + "defaultValue": "POSITION" } ], "type": { @@ -17403,7 +17503,7 @@ }, { "name": "options", - "description": "List of custom product options (maximum of 3 per product).", + "description": "List of product options.", "args": [ { "name": "first", @@ -17569,6 +17669,22 @@ "isDeprecated": false, "deprecationReason": null }, + { + "name": "seo", + "description": "The product's SEO information.", + "args": [], + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "OBJECT", + "name": "SEO", + "ofType": null + } + }, + "isDeprecated": false, + "deprecationReason": null + }, { "name": "tags", "description": "A comma separated list of tags that have been added to the product.\nAdditional access scope required for private apps: unauthenticated_read_product_tags.\n", @@ -17623,7 +17739,7 @@ }, { "name": "updatedAt", - "description": "The date and time when the product was last modified.", + "description": "The date and time when the product was last modified.\nA product's `updatedAt` value can change for different reasons. For example, if an order\nis placed for a product that has inventory tracking set up, then the inventory adjustment\nis counted as an update.\n", "args": [], "type": { "kind": "NON_NULL", @@ -17844,7 +17960,7 @@ { "kind": "OBJECT", "name": "ProductConnection", - "description": null, + "description": "An auto-generated type for paginating through multiple Products.\n", "fields": [ { "name": "edges", @@ -17895,7 +18011,7 @@ { "kind": "OBJECT", "name": "ProductEdge", - "description": null, + "description": "An auto-generated type which holds one Product and a cursor during pagination.\n", "fields": [ { "name": "cursor", @@ -17970,10 +18086,39 @@ ], "possibleTypes": null }, + { + "kind": "ENUM", + "name": "ProductMediaSortKeys", + "description": "The set of valid sort keys for the ProductMedia query.", + "fields": null, + "inputFields": null, + "interfaces": null, + "enumValues": [ + { + "name": "POSITION", + "description": "Sort by the `position` value.", + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "ID", + "description": "Sort by the `id` value.", + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "RELEVANCE", + "description": "During a search (i.e. when the `query` parameter has been specified on the connection) this sorts the\nresults by relevance to the search term(s). When no search query is specified, this sort key is not\ndeterministic and should not be used.\n", + "isDeprecated": false, + "deprecationReason": null + } + ], + "possibleTypes": null + }, { "kind": "OBJECT", "name": "ProductOption", - "description": "Custom product property names like \"Size\", \"Color\", and \"Material\".\nProducts are based on permutations of these options.\nA product may have a maximum of 3 options.\n255 characters limit each.\n", + "description": "Product property names like \"Size\", \"Color\", and \"Material\" that the customers can select.\nVariants are selected based on permutations of these options.\n255 characters limit each.\n", "fields": [ { "name": "id", @@ -18089,7 +18234,7 @@ { "kind": "OBJECT", "name": "ProductPriceRangeConnection", - "description": null, + "description": "An auto-generated type for paginating through multiple ProductPriceRanges.\n", "fields": [ { "name": "edges", @@ -18140,7 +18285,7 @@ { "kind": "OBJECT", "name": "ProductPriceRangeEdge", - "description": null, + "description": "An auto-generated type which holds one ProductPriceRange and a cursor during pagination.\n", "fields": [ { "name": "cursor", @@ -18875,7 +19020,7 @@ { "kind": "OBJECT", "name": "ProductVariantConnection", - "description": null, + "description": "An auto-generated type for paginating through multiple ProductVariants.\n", "fields": [ { "name": "edges", @@ -18926,7 +19071,7 @@ { "kind": "OBJECT", "name": "ProductVariantEdge", - "description": null, + "description": "An auto-generated type which holds one ProductVariant and a cursor during pagination.\n", "fields": [ { "name": "cursor", @@ -19008,7 +19153,7 @@ { "kind": "OBJECT", "name": "ProductVariantPricePairConnection", - "description": null, + "description": "An auto-generated type for paginating through multiple ProductVariantPricePairs.\n", "fields": [ { "name": "edges", @@ -19059,7 +19204,7 @@ { "kind": "OBJECT", "name": "ProductVariantPricePairEdge", - "description": null, + "description": "An auto-generated type which holds one ProductVariantPricePair and a cursor during pagination.\n", "fields": [ { "name": "cursor", @@ -19489,7 +19634,7 @@ }, { "name": "node", - "description": null, + "description": "Returns a specific node by ID.", "args": [ { "name": "id", @@ -19516,7 +19661,7 @@ }, { "name": "nodes", - "description": null, + "description": "Returns the list of nodes with the given IDs.", "args": [ { "name": "ids", @@ -20079,7 +20224,7 @@ { "kind": "OBJECT", "name": "SelectedOption", - "description": "Custom properties that a shop owner can use to define product variants.\nMultiple options can exist. Options are represented as: option1, option2, option3, etc.\n", + "description": "Properties used by customers to select a product variant.\nProducts can have multiple options, like different sizes or colors.\n", "fields": [ { "name": "name", @@ -20659,7 +20804,7 @@ }, { "name": "productTags", - "description": "A comma separated list of tags that have been added to products.\nAdditional access scope required: unauthenticated_read_product_tags.\n", + "description": "A list of tags that have been added to products.\nAdditional access scope required: unauthenticated_read_product_tags.\n", "args": [ { "name": "first", @@ -20818,6 +20963,18 @@ "isDeprecated": false, "deprecationReason": null }, + { + "name": "shippingPolicy", + "description": "The shop’s shipping policy.", + "args": [], + "type": { + "kind": "OBJECT", + "name": "ShopPolicy", + "ofType": null + }, + "isDeprecated": false, + "deprecationReason": null + }, { "name": "shipsToCountries", "description": "Countries that the shop ships to.", @@ -20982,7 +21139,7 @@ { "kind": "OBJECT", "name": "StringConnection", - "description": null, + "description": "An auto-generated type for paginating through multiple Strings.\n", "fields": [ { "name": "edges", @@ -21033,7 +21190,7 @@ { "kind": "OBJECT", "name": "StringEdge", - "description": null, + "description": "An auto-generated type which holds one String and a cursor during pagination.\n", "fields": [ { "name": "cursor", @@ -21482,38 +21639,38 @@ { "kind": "ENUM", "name": "TransactionKind", - "description": null, + "description": "The different kinds of order transactions.", "fields": null, "inputFields": null, "interfaces": null, "enumValues": [ { "name": "SALE", - "description": null, + "description": "An authorization and capture performed together in a single step.", "isDeprecated": false, "deprecationReason": null }, { "name": "CAPTURE", - "description": null, + "description": "A transfer of the money that was reserved during the authorization stage.", "isDeprecated": false, "deprecationReason": null }, { "name": "AUTHORIZATION", - "description": null, + "description": "An amount reserved against the cardholder's funding source.\nMoney does not change hands until the authorization is captured.\n", "isDeprecated": false, "deprecationReason": null }, { "name": "EMV_AUTHORIZATION", - "description": null, + "description": "An authorization for a payment taken with an EMV credit card reader.", "isDeprecated": false, "deprecationReason": null }, { "name": "CHANGE", - "description": null, + "description": "Money returned to the customer when they have paid too much.", "isDeprecated": false, "deprecationReason": null } @@ -21523,32 +21680,32 @@ { "kind": "ENUM", "name": "TransactionStatus", - "description": null, + "description": "Transaction statuses describe the status of a transaction.", "fields": null, "inputFields": null, "interfaces": null, "enumValues": [ { "name": "PENDING", - "description": null, + "description": "The transaction is pending.", "isDeprecated": false, "deprecationReason": null }, { "name": "SUCCESS", - "description": null, + "description": "The transaction succeeded.", "isDeprecated": false, "deprecationReason": null }, { "name": "FAILURE", - "description": null, + "description": "The transaction failed.", "isDeprecated": false, "deprecationReason": null }, { "name": "ERROR", - "description": null, + "description": "There was an error while processing the transaction.", "isDeprecated": false, "deprecationReason": null } @@ -22394,7 +22551,18 @@ { "name": "args", "description": null, - "args": [], + "args": [ + { + "name": "includeDeprecated", + "description": null, + "type": { + "kind": "SCALAR", + "name": "Boolean", + "ofType": null + }, + "defaultValue": "false" + } + ], "type": { "kind": "NON_NULL", "name": null, @@ -22522,6 +22690,18 @@ "isDeprecated": false, "deprecationReason": null }, + { + "name": "deprecationReason", + "description": null, + "args": [], + "type": { + "kind": "SCALAR", + "name": "String", + "ofType": null + }, + "isDeprecated": false, + "deprecationReason": null + }, { "name": "description", "description": null, @@ -22534,6 +22714,22 @@ "isDeprecated": false, "deprecationReason": null }, + { + "name": "isDeprecated", + "description": null, + "args": [], + "type": { + "kind": "NON_NULL", + "name": null, + "ofType": { + "kind": "SCALAR", + "name": "Boolean", + "ofType": null + } + }, + "isDeprecated": false, + "deprecationReason": null + }, { "name": "name", "description": null, @@ -22793,7 +22989,18 @@ { "name": "inputFields", "description": null, - "args": [], + "args": [ + { + "name": "includeDeprecated", + "description": null, + "type": { + "kind": "SCALAR", + "name": "Boolean", + "ofType": null + }, + "defaultValue": "false" + } + ], "type": { "kind": "LIST", "name": null, @@ -23024,7 +23231,9 @@ "description": "Marks an element of a GraphQL schema as no longer supported.", "locations": [ "FIELD_DEFINITION", - "ENUM_VALUE" + "ENUM_VALUE", + "ARGUMENT_DEFINITION", + "INPUT_FIELD_DEFINITION" ], "args": [ { diff --git a/src/config.js b/src/config.js index 23a7ef7ec..12f81414d 100644 --- a/src/config.js +++ b/src/config.js @@ -57,7 +57,7 @@ class Config { if (attrs.hasOwnProperty('apiVersion')) { this.apiVersion = attrs.apiVersion; } else { - this.apiVersion = '2020-07'; + this.apiVersion = '2021-01'; } if (attrs.hasOwnProperty('source')) { diff --git a/test/client-test.js b/test/client-test.js index aa938cc53..2c645b70c 100644 --- a/test/client-test.js +++ b/test/client-test.js @@ -9,7 +9,7 @@ suite('client-test', () => { const config = { domain: 'sendmecats.myshopify.com', storefrontAccessToken: 'abc123', - apiVersion: '2020-07' + apiVersion: '2021-01' }; test('it instantiates a GraphQL client with the given config', () => { diff --git a/test/product-helpers-test.js b/test/product-helpers-test.js index c9fd056de..12fb4f975 100644 --- a/test/product-helpers-test.js +++ b/test/product-helpers-test.js @@ -6,7 +6,7 @@ import singleProductFixture from '../fixtures/product-fixture'; import types from '../schema.json'; suite('product-helpers-test', () => { - const graphQLClient = new GraphQLJSClient(types, {url: 'https://sendmecats.myshopify.com/api/2020-07/graphql'}); + const graphQLClient = new GraphQLJSClient(types, {url: 'https://sendmecats.myshopify.com/api/2021-01/graphql'}); const query = productNodeQuery(graphQLClient) .definitions .find((definition) => definition.operationType === 'query'); From 839d24c8e8f4a6f7bfff61707cd03b2dc22f98c5 Mon Sep 17 00:00:00 2001 From: Isamu Arimoto Date: Fri, 12 Mar 2021 10:09:06 +0900 Subject: [PATCH 02/13] add customerResource --- src/client.js | 2 ++ src/customer-resource.js | 39 ++++++++++++++++++++++ src/graphql/customerCreateMutation.graphql | 12 +++++++ 3 files changed, 53 insertions(+) create mode 100644 src/customer-resource.js create mode 100644 src/graphql/customerCreateMutation.graphql diff --git a/src/client.js b/src/client.js index 1bd350913..85d04f850 100644 --- a/src/client.js +++ b/src/client.js @@ -4,6 +4,7 @@ import ProductResource from './product-resource'; import CollectionResource from './collection-resource'; import ShopResource from './shop-resource'; import CheckoutResource from './checkout-resource'; +import CustomerResource from './customer-resource'; import ImageResource from './image-resource'; import {version} from '../package.json'; @@ -80,6 +81,7 @@ class Client { this.collection = new CollectionResource(this.graphQLClient); this.shop = new ShopResource(this.graphQLClient); this.checkout = new CheckoutResource(this.graphQLClient); + this.customer = new CustomerResource(this.graphQLClient); this.image = new ImageResource(this.graphQLClient); } diff --git a/src/customer-resource.js b/src/customer-resource.js new file mode 100644 index 000000000..d1b10ed63 --- /dev/null +++ b/src/customer-resource.js @@ -0,0 +1,39 @@ +import Resource from './resource'; +import defaultResolver from './default-resolver'; + +// GraphQL +import customerCreateMutation from './graphql/customerCreateMutation.graphql'; + +/** + * The JS Buy SDK customer resource + * @class + */ +class CustomerResource extends Resource { + + /** + * Creates a customer. + * + * @example + * const input = { + * email: "isamu@to-kyo.to", + * password: "HiZqFuDvDdQ7" + * }; + * + * client.customer.create(input).then((customer) => { + * // Do something with the newly created customer + * }); + * + * @param {Object} [input] An input object containing of: + * @param {String} [input.email] The customer’s email + * @param {String} [input.password] The login password used by the customer. + * @return {Promise|GraphModel} A promise resolving with the created customer. + */ + create(input) { + return this.graphQLClient + .send(customerCreateMutation, {input}) + .then(defaultResolver('customerCreate.customer')); + } + +} + +export default CustomerResource; diff --git a/src/graphql/customerCreateMutation.graphql b/src/graphql/customerCreateMutation.graphql new file mode 100644 index 000000000..c928a4d13 --- /dev/null +++ b/src/graphql/customerCreateMutation.graphql @@ -0,0 +1,12 @@ +mutation customerCreate($input: CustomerCreateInput!) { + customerCreate(input: $input) { + customer { + id + } + customerUserErrors { + code + field + message + } + } +} From 231cb448dd69c75742afdad0a4ec35e72ace6b4a Mon Sep 17 00:00:00 2001 From: Isamu Arimoto Date: Fri, 12 Mar 2021 13:03:10 +0900 Subject: [PATCH 03/13] add customer createAccessToken --- src/customer-resource.js | 6 ++++++ .../customerAccessTokenCreateMutation.graphql | 13 +++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 src/graphql/customerAccessTokenCreateMutation.graphql diff --git a/src/customer-resource.js b/src/customer-resource.js index d1b10ed63..4b7b9864f 100644 --- a/src/customer-resource.js +++ b/src/customer-resource.js @@ -3,6 +3,7 @@ import defaultResolver from './default-resolver'; // GraphQL import customerCreateMutation from './graphql/customerCreateMutation.graphql'; +import customerAccessTokenCreateMutation from './graphql/customerAccessTokenCreateMutation.graphql'; /** * The JS Buy SDK customer resource @@ -34,6 +35,11 @@ class CustomerResource extends Resource { .then(defaultResolver('customerCreate.customer')); } + createAccessToken(input) { + return this.graphQLClient + .send(customerAccessTokenCreateMutation, {input}) + } + } export default CustomerResource; diff --git a/src/graphql/customerAccessTokenCreateMutation.graphql b/src/graphql/customerAccessTokenCreateMutation.graphql new file mode 100644 index 000000000..6ac0a7bc1 --- /dev/null +++ b/src/graphql/customerAccessTokenCreateMutation.graphql @@ -0,0 +1,13 @@ +mutation customerAccessTokenCreate($input: CustomerAccessTokenCreateInput!) { + customerAccessTokenCreate(input: $input) { + customerAccessToken { + accessToken + expiresAt + } + customerUserErrors { + code + field + message + } + } +} \ No newline at end of file From 3fc3f7a61e887b3097c6e34cdc3ebed24e042e54 Mon Sep 17 00:00:00 2001 From: Isamu Arimoto Date: Fri, 12 Mar 2021 13:45:40 +0900 Subject: [PATCH 04/13] add customer graphQLs --- .gitignore | 5 +- src/customer-resource.js | 84 +++++++++++++++++++ ...ssTokenCreateWithMultipassMutation.graphql | 13 +++ .../customerAccessTokenDeleteMutation.graphql | 10 +++ .../customerAccessTokenRenewMutation.graphql | 12 +++ .../customerActivateByUrlMutation.graphql | 16 ++++ src/graphql/customerActivateMutation.graphql | 16 ++++ .../customerAddressCreateMutation.graphql | 15 ++++ .../customerAddressDeleteMutation.graphql | 10 +++ .../customerAddressUpdateMutation.graphql | 16 ++++ ...stomerDefaultAddressUpdateMutation.graphql | 15 ++++ src/graphql/customerRecoverMutation.graphql | 9 ++ .../customerResetByUrlMutation.graphql | 16 ++++ src/graphql/customerResetMutation.graphql | 16 ++++ src/graphql/customerUpdateMutation.graphql | 16 ++++ 15 files changed, 268 insertions(+), 1 deletion(-) create mode 100644 src/graphql/customerAccessTokenCreateWithMultipassMutation.graphql create mode 100644 src/graphql/customerAccessTokenDeleteMutation.graphql create mode 100644 src/graphql/customerAccessTokenRenewMutation.graphql create mode 100644 src/graphql/customerActivateByUrlMutation.graphql create mode 100644 src/graphql/customerActivateMutation.graphql create mode 100644 src/graphql/customerAddressCreateMutation.graphql create mode 100644 src/graphql/customerAddressDeleteMutation.graphql create mode 100644 src/graphql/customerAddressUpdateMutation.graphql create mode 100644 src/graphql/customerDefaultAddressUpdateMutation.graphql create mode 100644 src/graphql/customerRecoverMutation.graphql create mode 100644 src/graphql/customerResetByUrlMutation.graphql create mode 100644 src/graphql/customerResetMutation.graphql create mode 100644 src/graphql/customerUpdateMutation.graphql diff --git a/.gitignore b/.gitignore index 0a6a5cda8..7723be302 100644 --- a/.gitignore +++ b/.gitignore @@ -20,4 +20,7 @@ secrets.json .nvmrc # VSCode settings -.vscode \ No newline at end of file +.vscode + +#Emacs +*~ \ No newline at end of file diff --git a/src/customer-resource.js b/src/customer-resource.js index 4b7b9864f..149f71922 100644 --- a/src/customer-resource.js +++ b/src/customer-resource.js @@ -3,7 +3,25 @@ import defaultResolver from './default-resolver'; // GraphQL import customerCreateMutation from './graphql/customerCreateMutation.graphql'; + import customerAccessTokenCreateMutation from './graphql/customerAccessTokenCreateMutation.graphql'; +import customerAccessTokenCreateWithMultipassMutation from './graphql/customerAccessTokenCreateWithMultipassMutation.graphql'; +import customerAccessTokenDeleteMutation from './graphql/customerAccessTokenDeleteMutation.graphql'; +import customerAccessTokenRenewMutation from './graphql/customerAccessTokenRenewMutation.graphql'; + +import customerActivateByUrlMutation from './graphql/customerActivateByUrlMutation.graphql'; +import customerActivateMutation from './graphql/customerActivateMutation.graphql'; + +import customerAddressCreateMutation from './graphql/customerAddressCreateMutation.graphql'; +import customerAddressDeleteMutation from './graphql/customerAddressDeleteMutation.graphql'; +import customerAddressUpdateMutation from './graphql/customerAddressUpdateMutation.graphql'; + +import customerDefaultAddressUpdateMutation from './graphql/customerDefaultAddressUpdateMutation.graphql'; +import customerRecoverMutation from './graphql/customerRecoverMutation.graphql'; +import customerResetByUrlMutation from './graphql/customerResetByUrlMutation.graphql'; +import customerResetMutation from './graphql/customerResetMutation.graphql'; + +import customerUpdateMutation from './graphql/customerUpdateMutation.graphql'; /** * The JS Buy SDK customer resource @@ -38,8 +56,74 @@ class CustomerResource extends Resource { createAccessToken(input) { return this.graphQLClient .send(customerAccessTokenCreateMutation, {input}) + .then(defaultResolver('customerAccessTokenCreate.customerAccessToken')); + } + + // not implemented + createAccessTokenWithMultipass(multipassToken) { + return this.graphQLClient + .send(customerAccessTokenCreateWithMultipassMutation, {multipassToken}); + } + + deleteAccessToken(customerAccessToken) { + return this.graphQLClient + .send(customerAccessTokenDeleteMutation, {customerAccessToken}); } + renewAccessToken(customerAccessToken) { + return this.graphQLClient + .send(customerAccessTokenRenewMutation, {customerAccessToken}); + } + + activate(id, input) { + return this.graphQLClient + .send(customerActivateMutation, {id, input}) + } + + activateByUrl(activationUrl, password) { + return this.graphQLClient + .send(customerActivateByUrlMutation, {activationUrl, password}); + } + + createAddress(customerAccessToken, address) { + return this.graphQLClient + .send(customerAddressCreateMutation, {customerAccessToken, address}); + } + + deleteAddress(id, customerAccessToken) { + return this.graphQLClient + .send(customerAddressDeleteMutation, {id, customerAccessToken}); + } + + updateAddress(customerAccessToken, id, address) { + return this.graphQLClient + .send(customerAddressUpdateMutation, {customerAccessToken, id, address}); + } + + updateDefaultAddress(customerAccessToken, addressId) { + return this.graphQLClient + .send(customerDefaultAddressUpdateMutation, {customerAccessToken, addressId}); + } + + recover(email) { + return this.graphQLClient + .send(customerRecoverMutation, {email}); + } + + reset(id, input) { + return this.graphQLClient + .send(customerResetMutation, {id, input}); + } + + resetByUrl(resetUrl, password) { + return this.graphQLClient + .send(customerResetByUrlMutation, {resetUrl, password}); + } + + update(customerAccessToken, customer) { + return this.graphQLClient + .send(customerUpdateMutation, {customerAccessToken, customer}); + } } export default CustomerResource; diff --git a/src/graphql/customerAccessTokenCreateWithMultipassMutation.graphql b/src/graphql/customerAccessTokenCreateWithMultipassMutation.graphql new file mode 100644 index 000000000..d8b6b3d2c --- /dev/null +++ b/src/graphql/customerAccessTokenCreateWithMultipassMutation.graphql @@ -0,0 +1,13 @@ +mutation customerAccessTokenCreateWithMultipass($multipassToken: String!) { + customerAccessTokenCreateWithMultipass(multipassToken: $multipassToken) { + customerAccessToken { + accessToken + expiresAt + } + customerUserErrors { + code + field + message + } + } +} \ No newline at end of file diff --git a/src/graphql/customerAccessTokenDeleteMutation.graphql b/src/graphql/customerAccessTokenDeleteMutation.graphql new file mode 100644 index 000000000..aa0db5fe8 --- /dev/null +++ b/src/graphql/customerAccessTokenDeleteMutation.graphql @@ -0,0 +1,10 @@ +mutation customerAccessTokenDelete($customerAccessToken: String!) { + customerAccessTokenDelete(customerAccessToken: $customerAccessToken) { + deletedAccessToken + deletedCustomerAccessTokenId + userErrors { + field + message + } + } +} \ No newline at end of file diff --git a/src/graphql/customerAccessTokenRenewMutation.graphql b/src/graphql/customerAccessTokenRenewMutation.graphql new file mode 100644 index 000000000..6115070db --- /dev/null +++ b/src/graphql/customerAccessTokenRenewMutation.graphql @@ -0,0 +1,12 @@ +mutation customerAccessTokenRenew($customerAccessToken: String!) { + customerAccessTokenRenew(customerAccessToken: $customerAccessToken) { + customerAccessToken { + accessToken + expiresAt + } + userErrors { + field + message + } + } +} \ No newline at end of file diff --git a/src/graphql/customerActivateByUrlMutation.graphql b/src/graphql/customerActivateByUrlMutation.graphql new file mode 100644 index 000000000..870c562a8 --- /dev/null +++ b/src/graphql/customerActivateByUrlMutation.graphql @@ -0,0 +1,16 @@ +mutation customerActivateByUrl($activationUrl: URL!, $password: String!) { + customerActivateByUrl(activationUrl: $activationUrl, password: $password) { + customer { + id + } + customerAccessToken { + accessToken + expiresAt + } + customerUserErrors { + code + field + message + } + } +} \ No newline at end of file diff --git a/src/graphql/customerActivateMutation.graphql b/src/graphql/customerActivateMutation.graphql new file mode 100644 index 000000000..5421ba2b9 --- /dev/null +++ b/src/graphql/customerActivateMutation.graphql @@ -0,0 +1,16 @@ +mutation customerActivate($id: ID!, $input: CustomerActivateInput!) { + customerActivate(id: $id, input: $input) { + customer { + id + } + customerAccessToken { + accessToken + expiresAt + } + customerUserErrors { + code + field + message + } + } +} \ No newline at end of file diff --git a/src/graphql/customerAddressCreateMutation.graphql b/src/graphql/customerAddressCreateMutation.graphql new file mode 100644 index 000000000..bd9a48be5 --- /dev/null +++ b/src/graphql/customerAddressCreateMutation.graphql @@ -0,0 +1,15 @@ +mutation customerAddressCreate($customerAccessToken: String!, $address: MailingAddressInput!) { + customerAddressCreate( + customerAccessToken: $customerAccessToken + address: $address + ) { + customerAddress { + id + } + customerUserErrors { + code + field + message + } + } +} diff --git a/src/graphql/customerAddressDeleteMutation.graphql b/src/graphql/customerAddressDeleteMutation.graphql new file mode 100644 index 000000000..915f6ad52 --- /dev/null +++ b/src/graphql/customerAddressDeleteMutation.graphql @@ -0,0 +1,10 @@ +mutation customerAddressDelete($id: ID!, $customerAccessToken: String!) { + customerAddressDelete(id: $id, customerAccessToken: $customerAccessToken) { + customerUserErrors { + code + field + message + } + deletedCustomerAddressId + } +} \ No newline at end of file diff --git a/src/graphql/customerAddressUpdateMutation.graphql b/src/graphql/customerAddressUpdateMutation.graphql new file mode 100644 index 000000000..a80e7a477 --- /dev/null +++ b/src/graphql/customerAddressUpdateMutation.graphql @@ -0,0 +1,16 @@ +mutation customerAddressUpdate($customerAccessToken: String!, $id: ID!, $address: MailingAddressInput!) { + customerAddressUpdate( + customerAccessToken: $customerAccessToken + id: $id + address: $address + ) { + customerAddress { + id + } + customerUserErrors { + code + field + message + } + } +} \ No newline at end of file diff --git a/src/graphql/customerDefaultAddressUpdateMutation.graphql b/src/graphql/customerDefaultAddressUpdateMutation.graphql new file mode 100644 index 000000000..9939c90d0 --- /dev/null +++ b/src/graphql/customerDefaultAddressUpdateMutation.graphql @@ -0,0 +1,15 @@ +mutation customerDefaultAddressUpdate($customerAccessToken: String!, $addressId: ID!) { + customerDefaultAddressUpdate( + customerAccessToken: $customerAccessToken + addressId: $addressId + ) { + customer { + id + } + customerUserErrors { + code + field + message + } + } +} \ No newline at end of file diff --git a/src/graphql/customerRecoverMutation.graphql b/src/graphql/customerRecoverMutation.graphql new file mode 100644 index 000000000..5e7d6c480 --- /dev/null +++ b/src/graphql/customerRecoverMutation.graphql @@ -0,0 +1,9 @@ +mutation customerRecover($email: String!) { + customerRecover(email: $email) { + customerUserErrors { + code + field + message + } + } +} diff --git a/src/graphql/customerResetByUrlMutation.graphql b/src/graphql/customerResetByUrlMutation.graphql new file mode 100644 index 000000000..0c4d37443 --- /dev/null +++ b/src/graphql/customerResetByUrlMutation.graphql @@ -0,0 +1,16 @@ +mutation customerResetByUrl($resetUrl: URL!, $password: String!) { + customerResetByUrl(resetUrl: $resetUrl, password: $password) { + customer { + id + } + customerAccessToken { + accessToken + expiresAt + } + customerUserErrors { + code + field + message + } + } +} \ No newline at end of file diff --git a/src/graphql/customerResetMutation.graphql b/src/graphql/customerResetMutation.graphql new file mode 100644 index 000000000..3b1d4d248 --- /dev/null +++ b/src/graphql/customerResetMutation.graphql @@ -0,0 +1,16 @@ +mutation customerReset($id: ID!, $input: CustomerResetInput!) { + customerReset(id: $id, input: $input) { + customer { + id + } + customerAccessToken { + accessToken + expiresAt + } + customerUserErrors { + code + field + message + } + } +} \ No newline at end of file diff --git a/src/graphql/customerUpdateMutation.graphql b/src/graphql/customerUpdateMutation.graphql new file mode 100644 index 000000000..af4332f69 --- /dev/null +++ b/src/graphql/customerUpdateMutation.graphql @@ -0,0 +1,16 @@ +mutation customerUpdate($customerAccessToken: String!, $customer: CustomerUpdateInput!) { + customerUpdate(customerAccessToken: $customerAccessToken, customer: $customer) { + customer { + id + } + customerAccessToken { + accessToken + expiresAt + } + customerUserErrors { + code + field + message + } + } +} \ No newline at end of file From 126357400e1fe908888e917d005c45c2883cee30 Mon Sep 17 00:00:00 2001 From: Isamu Arimoto Date: Fri, 12 Mar 2021 18:25:52 +0900 Subject: [PATCH 05/13] update customer api response --- src/customer-resource.js | 58 +++++++++++++++++++++++++--------------- 1 file changed, 36 insertions(+), 22 deletions(-) diff --git a/src/customer-resource.js b/src/customer-resource.js index 149f71922..565912c18 100644 --- a/src/customer-resource.js +++ b/src/customer-resource.js @@ -50,80 +50,94 @@ class CustomerResource extends Resource { create(input) { return this.graphQLClient .send(customerCreateMutation, {input}) - .then(defaultResolver('customerCreate.customer')); + .then(defaultResolver('customerCreate')); } - createAccessToken(input) { + update(customerAccessToken, customer) { return this.graphQLClient - .send(customerAccessTokenCreateMutation, {input}) - .then(defaultResolver('customerAccessTokenCreate.customerAccessToken')); + .send(customerUpdateMutation, {customerAccessToken, customer}) + .then(defaultResolver('customerUpdate')); } - // not implemented - createAccessTokenWithMultipass(multipassToken) { + createAccessToken(input) { return this.graphQLClient - .send(customerAccessTokenCreateWithMultipassMutation, {multipassToken}); + .send(customerAccessTokenCreateMutation, {input}) + .then(defaultResolver('customerAccessTokenCreate')); } - + deleteAccessToken(customerAccessToken) { return this.graphQLClient - .send(customerAccessTokenDeleteMutation, {customerAccessToken}); + .send(customerAccessTokenDeleteMutation, {customerAccessToken}) + .then(defaultResolver('customerAccessTokenDelete')); + } renewAccessToken(customerAccessToken) { return this.graphQLClient - .send(customerAccessTokenRenewMutation, {customerAccessToken}); + .send(customerAccessTokenRenewMutation, {customerAccessToken}) + .then(defaultResolver('customerAccessTokenRenew')); } + createAccessTokenWithMultipass(multipassToken) { + return this.graphQLClient + .send(customerAccessTokenCreateWithMultipassMutation, {multipassToken}) + .then(defaultResolver('customerAccessTokenCreateWithMultipass')); + } + activate(id, input) { return this.graphQLClient .send(customerActivateMutation, {id, input}) + .then(defaultResolver('customerActivate')); } activateByUrl(activationUrl, password) { return this.graphQLClient - .send(customerActivateByUrlMutation, {activationUrl, password}); + .send(customerActivateByUrlMutation, {activationUrl, password}) + .then(defaultResolver('customerActivateByUrl')); } createAddress(customerAccessToken, address) { return this.graphQLClient - .send(customerAddressCreateMutation, {customerAccessToken, address}); + .send(customerAddressCreateMutation, {customerAccessToken, address}) + .then(defaultResolver('customerAddressCreate')); } deleteAddress(id, customerAccessToken) { return this.graphQLClient - .send(customerAddressDeleteMutation, {id, customerAccessToken}); + .send(customerAddressDeleteMutation, {id, customerAccessToken}) + .then(defaultResolver('customerAddressDelete')); } updateAddress(customerAccessToken, id, address) { return this.graphQLClient - .send(customerAddressUpdateMutation, {customerAccessToken, id, address}); + .send(customerAddressUpdateMutation, {customerAccessToken, id, address}) + .then(defaultResolver('customerAddressUpdate')); } updateDefaultAddress(customerAccessToken, addressId) { return this.graphQLClient - .send(customerDefaultAddressUpdateMutation, {customerAccessToken, addressId}); + .send(customerDefaultAddressUpdateMutation, {customerAccessToken, addressId}) + .then(defaultResolver('customerDefaultAddressUpdate')); } recover(email) { return this.graphQLClient - .send(customerRecoverMutation, {email}); + .send(customerRecoverMutation, {email}) + .then(defaultResolver('customerRecover')); } reset(id, input) { return this.graphQLClient - .send(customerResetMutation, {id, input}); + .send(customerResetMutation, {id, input}) + .then(defaultResolver('customerReset')); } resetByUrl(resetUrl, password) { return this.graphQLClient - .send(customerResetByUrlMutation, {resetUrl, password}); + .send(customerResetByUrlMutation, {resetUrl, password}) + .then(defaultResolver('customerResetByUrl')); } - update(customerAccessToken, customer) { - return this.graphQLClient - .send(customerUpdateMutation, {customerAccessToken, customer}); - } } export default CustomerResource; From 5c08f659e2e7b050b2fc94e2b796df12b2656331 Mon Sep 17 00:00:00 2001 From: Isamu Arimoto Date: Fri, 12 Mar 2021 18:33:32 +0900 Subject: [PATCH 06/13] add comments for customer --- src/customer-resource.js | 56 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/src/customer-resource.js b/src/customer-resource.js index 565912c18..38a5b112c 100644 --- a/src/customer-resource.js +++ b/src/customer-resource.js @@ -53,18 +53,30 @@ class CustomerResource extends Resource { .then(defaultResolver('customerCreate')); } + /** + * Update a customer. + * + */ update(customerAccessToken, customer) { return this.graphQLClient .send(customerUpdateMutation, {customerAccessToken, customer}) .then(defaultResolver('customerUpdate')); } + /** + * Create a access token. + * + */ createAccessToken(input) { return this.graphQLClient .send(customerAccessTokenCreateMutation, {input}) .then(defaultResolver('customerAccessTokenCreate')); } + /** + * Delete a access token. + * + */ deleteAccessToken(customerAccessToken) { return this.graphQLClient .send(customerAccessTokenDeleteMutation, {customerAccessToken}) @@ -72,66 +84,110 @@ class CustomerResource extends Resource { } + /** + * Renew a access token. + * + */ renewAccessToken(customerAccessToken) { return this.graphQLClient .send(customerAccessTokenRenewMutation, {customerAccessToken}) .then(defaultResolver('customerAccessTokenRenew')); } + /** + * Create a access token with Multipass. + * + */ createAccessTokenWithMultipass(multipassToken) { return this.graphQLClient .send(customerAccessTokenCreateWithMultipassMutation, {multipassToken}) .then(defaultResolver('customerAccessTokenCreateWithMultipass')); } + /** + * Activate customer account. + * + */ activate(id, input) { return this.graphQLClient .send(customerActivateMutation, {id, input}) .then(defaultResolver('customerActivate')); } + /** + * Activate customer account by URL. + * + */ activateByUrl(activationUrl, password) { return this.graphQLClient .send(customerActivateByUrlMutation, {activationUrl, password}) .then(defaultResolver('customerActivateByUrl')); } + /** + * Create customer's address. + * + */ createAddress(customerAccessToken, address) { return this.graphQLClient .send(customerAddressCreateMutation, {customerAccessToken, address}) .then(defaultResolver('customerAddressCreate')); } + /** + * Delete customer's address. + * + */ deleteAddress(id, customerAccessToken) { return this.graphQLClient .send(customerAddressDeleteMutation, {id, customerAccessToken}) .then(defaultResolver('customerAddressDelete')); } + /** + * Update customer's address. + * + */ updateAddress(customerAccessToken, id, address) { return this.graphQLClient .send(customerAddressUpdateMutation, {customerAccessToken, id, address}) .then(defaultResolver('customerAddressUpdate')); } + /** + * Update customer's default address. + * + */ updateDefaultAddress(customerAccessToken, addressId) { return this.graphQLClient .send(customerDefaultAddressUpdateMutation, {customerAccessToken, addressId}) .then(defaultResolver('customerDefaultAddressUpdate')); } + /** + * Recover customer. + * + */ recover(email) { return this.graphQLClient .send(customerRecoverMutation, {email}) .then(defaultResolver('customerRecover')); } + /** + * Reset customer password. + * + */ reset(id, input) { return this.graphQLClient .send(customerResetMutation, {id, input}) .then(defaultResolver('customerReset')); } + /** + * Reset customer password by Url. + * + */ resetByUrl(resetUrl, password) { return this.graphQLClient .send(customerResetByUrlMutation, {resetUrl, password}) From 1b0d48e14bc8102da026ebb4642922229ccc7798 Mon Sep 17 00:00:00 2001 From: Isamu Arimoto Date: Fri, 12 Mar 2021 18:38:55 +0900 Subject: [PATCH 07/13] fix lint --- src/customer-resource.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/customer-resource.js b/src/customer-resource.js index 38a5b112c..82437928e 100644 --- a/src/customer-resource.js +++ b/src/customer-resource.js @@ -81,9 +81,8 @@ class CustomerResource extends Resource { return this.graphQLClient .send(customerAccessTokenDeleteMutation, {customerAccessToken}) .then(defaultResolver('customerAccessTokenDelete')); - } - + /** * Renew a access token. * @@ -103,7 +102,7 @@ class CustomerResource extends Resource { .send(customerAccessTokenCreateWithMultipassMutation, {multipassToken}) .then(defaultResolver('customerAccessTokenCreateWithMultipass')); } - + /** * Activate customer account. * From e8cf6650b738f47664120a35217fdd84b9af0c1e Mon Sep 17 00:00:00 2001 From: Isamu Arimoto Date: Wed, 24 Mar 2021 09:31:53 +0900 Subject: [PATCH 08/13] add checkoutCustomerAssociateV2 --- src/checkout-resource.js | 7 +++++++ .../checkoutCustomerAssociateV2.graphql | 18 ++++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 src/graphql/checkoutCustomerAssociateV2.graphql diff --git a/src/checkout-resource.js b/src/checkout-resource.js index 878dd5ab0..fd873d65e 100644 --- a/src/checkout-resource.js +++ b/src/checkout-resource.js @@ -5,6 +5,7 @@ import handleCheckoutMutation from './handle-checkout-mutation'; // GraphQL import checkoutNodeQuery from './graphql/checkoutNodeQuery.graphql'; import checkoutCreateMutation from './graphql/checkoutCreateMutation.graphql'; +import checkoutCustomerAssociateV2 from './graphql/checkoutCustomerAssociateV2.graphql'; import checkoutLineItemsAddMutation from './graphql/checkoutLineItemsAddMutation.graphql'; import checkoutLineItemsRemoveMutation from './graphql/checkoutLineItemsRemoveMutation.graphql'; import checkoutLineItemsReplaceMutation from './graphql/checkoutLineItemsReplaceMutation.graphql'; @@ -78,6 +79,12 @@ class CheckoutResource extends Resource { .then(handleCheckoutMutation('checkoutCreate', this.graphQLClient)); } + associateCustomer(checkoutId, customerAccessToken) { + return this.graphQLClient + .send(checkoutCustomerAssociateV2, {checkoutId, customerAccessToken}) + .then(handleCheckoutMutation('checkoutCustomerAssociateV2', this.graphQLClient)); + } + /** * Replaces the value of checkout's custom attributes and/or note with values defined in the input * diff --git a/src/graphql/checkoutCustomerAssociateV2.graphql b/src/graphql/checkoutCustomerAssociateV2.graphql new file mode 100644 index 000000000..eb8a65439 --- /dev/null +++ b/src/graphql/checkoutCustomerAssociateV2.graphql @@ -0,0 +1,18 @@ +mutation checkoutCustomerAssociateV2($checkoutId: ID!, $customerAccessToken: String!) { + checkoutCustomerAssociateV2( + checkoutId: $checkoutId + customerAccessToken: $customerAccessToken + ) { + checkout { + id + } + checkoutUserErrors { + code + field + message + } + customer { + id + } + } +} From 041998b9cce8ed050799f1bb77fc45f0d98066bf Mon Sep 17 00:00:00 2001 From: Isamu Arimoto Date: Wed, 24 Mar 2021 10:13:43 +0900 Subject: [PATCH 09/13] add handleCustomerMutation --- src/customer-resource.js | 32 ++++++++++++++++---------------- src/handle-customer-mutation.js | 28 ++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 16 deletions(-) create mode 100644 src/handle-customer-mutation.js diff --git a/src/customer-resource.js b/src/customer-resource.js index 82437928e..1a78b9c9f 100644 --- a/src/customer-resource.js +++ b/src/customer-resource.js @@ -1,5 +1,5 @@ import Resource from './resource'; -import defaultResolver from './default-resolver'; +import handleCustomerMutation from './handle-customer-mutation'; // GraphQL import customerCreateMutation from './graphql/customerCreateMutation.graphql'; @@ -50,7 +50,7 @@ class CustomerResource extends Resource { create(input) { return this.graphQLClient .send(customerCreateMutation, {input}) - .then(defaultResolver('customerCreate')); + .then(handleCustomerMutation('customerCreate')); } /** @@ -60,7 +60,7 @@ class CustomerResource extends Resource { update(customerAccessToken, customer) { return this.graphQLClient .send(customerUpdateMutation, {customerAccessToken, customer}) - .then(defaultResolver('customerUpdate')); + .then(handleCustomerMutation('customerUpdate')); } /** @@ -70,7 +70,7 @@ class CustomerResource extends Resource { createAccessToken(input) { return this.graphQLClient .send(customerAccessTokenCreateMutation, {input}) - .then(defaultResolver('customerAccessTokenCreate')); + .then(handleCustomerMutation('customerAccessTokenCreate')); } /** @@ -80,7 +80,7 @@ class CustomerResource extends Resource { deleteAccessToken(customerAccessToken) { return this.graphQLClient .send(customerAccessTokenDeleteMutation, {customerAccessToken}) - .then(defaultResolver('customerAccessTokenDelete')); + .then(handleCustomerMutation('customerAccessTokenDelete')); } /** @@ -90,7 +90,7 @@ class CustomerResource extends Resource { renewAccessToken(customerAccessToken) { return this.graphQLClient .send(customerAccessTokenRenewMutation, {customerAccessToken}) - .then(defaultResolver('customerAccessTokenRenew')); + .then(handleCustomerMutation('customerAccessTokenRenew')); } /** @@ -100,7 +100,7 @@ class CustomerResource extends Resource { createAccessTokenWithMultipass(multipassToken) { return this.graphQLClient .send(customerAccessTokenCreateWithMultipassMutation, {multipassToken}) - .then(defaultResolver('customerAccessTokenCreateWithMultipass')); + .then(handleCustomerMutation('customerAccessTokenCreateWithMultipass')); } /** @@ -110,7 +110,7 @@ class CustomerResource extends Resource { activate(id, input) { return this.graphQLClient .send(customerActivateMutation, {id, input}) - .then(defaultResolver('customerActivate')); + .then(handleCustomerMutation('customerActivate')); } /** @@ -120,7 +120,7 @@ class CustomerResource extends Resource { activateByUrl(activationUrl, password) { return this.graphQLClient .send(customerActivateByUrlMutation, {activationUrl, password}) - .then(defaultResolver('customerActivateByUrl')); + .then(handleCustomerMutation('customerActivateByUrl')); } /** @@ -130,7 +130,7 @@ class CustomerResource extends Resource { createAddress(customerAccessToken, address) { return this.graphQLClient .send(customerAddressCreateMutation, {customerAccessToken, address}) - .then(defaultResolver('customerAddressCreate')); + .then(handleCustomerMutation('customerAddressCreate')); } /** @@ -140,7 +140,7 @@ class CustomerResource extends Resource { deleteAddress(id, customerAccessToken) { return this.graphQLClient .send(customerAddressDeleteMutation, {id, customerAccessToken}) - .then(defaultResolver('customerAddressDelete')); + .then(handleCustomerMutation('customerAddressDelete')); } /** @@ -150,7 +150,7 @@ class CustomerResource extends Resource { updateAddress(customerAccessToken, id, address) { return this.graphQLClient .send(customerAddressUpdateMutation, {customerAccessToken, id, address}) - .then(defaultResolver('customerAddressUpdate')); + .then(handleCustomerMutation('customerAddressUpdate')); } /** @@ -160,7 +160,7 @@ class CustomerResource extends Resource { updateDefaultAddress(customerAccessToken, addressId) { return this.graphQLClient .send(customerDefaultAddressUpdateMutation, {customerAccessToken, addressId}) - .then(defaultResolver('customerDefaultAddressUpdate')); + .then(handleCustomerMutation('customerDefaultAddressUpdate')); } /** @@ -170,7 +170,7 @@ class CustomerResource extends Resource { recover(email) { return this.graphQLClient .send(customerRecoverMutation, {email}) - .then(defaultResolver('customerRecover')); + .then(handleCustomerMutation('customerRecover')); } /** @@ -180,7 +180,7 @@ class CustomerResource extends Resource { reset(id, input) { return this.graphQLClient .send(customerResetMutation, {id, input}) - .then(defaultResolver('customerReset')); + .then(handleCustomerMutation('customerReset')); } /** @@ -190,7 +190,7 @@ class CustomerResource extends Resource { resetByUrl(resetUrl, password) { return this.graphQLClient .send(customerResetByUrlMutation, {resetUrl, password}) - .then(defaultResolver('customerResetByUrl')); + .then(handleCustomerMutation('customerResetByUrl')); } } diff --git a/src/handle-customer-mutation.js b/src/handle-customer-mutation.js new file mode 100644 index 000000000..29ec2c20b --- /dev/null +++ b/src/handle-customer-mutation.js @@ -0,0 +1,28 @@ +export default function handleCustomerMutation(mutationRootKey) { + return function({data = {}, errors, model = {}}) { + try { + const rootData = data[mutationRootKey]; + const rootModel = model[mutationRootKey]; + + if (errors && errors.length) { + return Promise.reject(new Error(JSON.stringify(errors))); + } + + if (rootData && rootData.customerUserErrors && rootData.customerUserErrors.length) { + return Promise.reject(new Error(JSON.stringify(rootData.customerUserErrors))); + } + + if (rootData && rootData.userErrors && rootData.userErrors.length) { + return Promise.reject(new Error(JSON.stringify(rootData.userErrors))); + } + + if (rootData) { + return rootData; + } + + return Promise.reject(new Error(`The ${mutationRootKey} mutation failed due to an unknown error.`)); + } catch (_) { + return Promise.reject(new Error(`The ${mutationRootKey} mutation failed due to an unknown error.`)); + } + }; +} From 3e5d92975d56049cea8391ccc1d8f94b33f11c51 Mon Sep 17 00:00:00 2001 From: Isamu Arimoto Date: Wed, 24 Mar 2021 13:57:17 +0900 Subject: [PATCH 10/13] fix lint --- src/checkout-resource.js | 2 +- src/handle-customer-mutation.js | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/checkout-resource.js b/src/checkout-resource.js index fd873d65e..146ad3d27 100644 --- a/src/checkout-resource.js +++ b/src/checkout-resource.js @@ -84,7 +84,7 @@ class CheckoutResource extends Resource { .send(checkoutCustomerAssociateV2, {checkoutId, customerAccessToken}) .then(handleCheckoutMutation('checkoutCustomerAssociateV2', this.graphQLClient)); } - + /** * Replaces the value of checkout's custom attributes and/or note with values defined in the input * diff --git a/src/handle-customer-mutation.js b/src/handle-customer-mutation.js index 29ec2c20b..5cb390ede 100644 --- a/src/handle-customer-mutation.js +++ b/src/handle-customer-mutation.js @@ -1,8 +1,7 @@ export default function handleCustomerMutation(mutationRootKey) { - return function({data = {}, errors, model = {}}) { + return function({data = {}, errors}) { try { const rootData = data[mutationRootKey]; - const rootModel = model[mutationRootKey]; if (errors && errors.length) { return Promise.reject(new Error(JSON.stringify(errors))); @@ -19,7 +18,7 @@ export default function handleCustomerMutation(mutationRootKey) { if (rootData) { return rootData; } - + return Promise.reject(new Error(`The ${mutationRootKey} mutation failed due to an unknown error.`)); } catch (_) { return Promise.reject(new Error(`The ${mutationRootKey} mutation failed due to an unknown error.`)); From cf0b6c846867b6c16562108151e2f75a19b16e1d Mon Sep 17 00:00:00 2001 From: Isamu Arimoto Date: Wed, 24 Mar 2021 17:01:38 +0900 Subject: [PATCH 11/13] add checkoutShippingLineUpdateMutation --- src/checkout-resource.js | 15 +++++++++++++++ .../checkoutShippingLineUpdateMutation.graphql | 15 +++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 src/graphql/checkoutShippingLineUpdateMutation.graphql diff --git a/src/checkout-resource.js b/src/checkout-resource.js index 146ad3d27..f0d0c37e5 100644 --- a/src/checkout-resource.js +++ b/src/checkout-resource.js @@ -17,6 +17,7 @@ import checkoutGiftCardsAppendMutation from './graphql/checkoutGiftCardsAppendMu import checkoutGiftCardRemoveV2Mutation from './graphql/checkoutGiftCardRemoveV2Mutation.graphql'; import checkoutEmailUpdateV2Mutation from './graphql/checkoutEmailUpdateV2Mutation.graphql'; import checkoutShippingAddressUpdateV2Mutation from './graphql/checkoutShippingAddressUpdateV2Mutation.graphql'; +import checkoutShippingLineUpdateMutation from './graphql/checkoutShippingLineUpdateMutation.graphql'; /** * The JS Buy SDK checkout resource @@ -333,6 +334,20 @@ class CheckoutResource extends Resource { .send(checkoutShippingAddressUpdateV2Mutation, {checkoutId, shippingAddress}) .then(handleCheckoutMutation('checkoutShippingAddressUpdateV2', this.graphQLClient)); } + + /** + * Updates the shipping lines on an existing checkout. + * + * @param {String} checkoutId The ID of the checkout to update shipping address. + * @param {Object} shippingRateHandle A unique identifier to a Checkout’s shipping provide + * @return {Promise|GraphModel} A promise resolving with the updated checkout. + */ + updateShippingLineAddress(checkoutId, shippingRateHandle) { + return this.graphQLClient + .send(checkoutShippingLineUpdateMutation, {checkoutId, shippingRateHandle}) + .then(handleCheckoutMutation('checkoutShippingLineUpdate', this.graphQLClient)); + } + } export default CheckoutResource; diff --git a/src/graphql/checkoutShippingLineUpdateMutation.graphql b/src/graphql/checkoutShippingLineUpdateMutation.graphql new file mode 100644 index 000000000..fe6009c95 --- /dev/null +++ b/src/graphql/checkoutShippingLineUpdateMutation.graphql @@ -0,0 +1,15 @@ +mutation checkoutShippingLineUpdate($checkoutId: ID!, $shippingRateHandle: String!) { + checkoutShippingLineUpdate( + checkoutId: $checkoutId + shippingRateHandle: $shippingRateHandle + ) { + checkout { + id + } + checkoutUserErrors { + code + field + message + } + } +} \ No newline at end of file From 26ba75a321b0bc9729c8bee001e7e7e47a9e6814 Mon Sep 17 00:00:00 2001 From: Isamu Arimoto Date: Sat, 3 Jul 2021 11:06:33 +0900 Subject: [PATCH 12/13] add customer.fetch api --- src/customer-resource.js | 8 ++++++++ src/graphql/customerNodeQuery.graphql | 7 +++++++ 2 files changed, 15 insertions(+) create mode 100644 src/graphql/customerNodeQuery.graphql diff --git a/src/customer-resource.js b/src/customer-resource.js index 1a78b9c9f..b5321af54 100644 --- a/src/customer-resource.js +++ b/src/customer-resource.js @@ -1,7 +1,10 @@ import Resource from './resource'; +import defaultResolver from './default-resolver'; import handleCustomerMutation from './handle-customer-mutation'; // GraphQL +import customerNodeQuery from './graphql/customerNodeQuery.graphql'; + import customerCreateMutation from './graphql/customerCreateMutation.graphql'; import customerAccessTokenCreateMutation from './graphql/customerAccessTokenCreateMutation.graphql'; @@ -28,6 +31,11 @@ import customerUpdateMutation from './graphql/customerUpdateMutation.graphql'; * @class */ class CustomerResource extends Resource { + fetch(customerAccessToken) { + return this.graphQLClient + .send(customerNodeQuery, {customerAccessToken}) + .then(defaultResolver('customer')) + } /** * Creates a customer. diff --git a/src/graphql/customerNodeQuery.graphql b/src/graphql/customerNodeQuery.graphql new file mode 100644 index 000000000..c37b2065c --- /dev/null +++ b/src/graphql/customerNodeQuery.graphql @@ -0,0 +1,7 @@ +query($customerAccessToken: String!) { + customer(customerAccessToken: $customerAccessToken) { + id + firstName + lastName + } +} From 57fe289f33c4d5582a2847f687bfddc91a24bd32 Mon Sep 17 00:00:00 2001 From: isamu Date: Sat, 16 Jul 2022 11:26:25 +0900 Subject: [PATCH 13/13] add tags --- src/graphql/customerNodeQuery.graphql | 1 + 1 file changed, 1 insertion(+) diff --git a/src/graphql/customerNodeQuery.graphql b/src/graphql/customerNodeQuery.graphql index c37b2065c..d4f09d7ce 100644 --- a/src/graphql/customerNodeQuery.graphql +++ b/src/graphql/customerNodeQuery.graphql @@ -3,5 +3,6 @@ query($customerAccessToken: String!) { id firstName lastName + tags } }