From 26ba75a321b0bc9729c8bee001e7e7e47a9e6814 Mon Sep 17 00:00:00 2001 From: Isamu Arimoto Date: Sat, 3 Jul 2021 11:06:33 +0900 Subject: [PATCH] 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 + } +}