Skip to content

Commit 77f02af

Browse files
committed
add customer.fetch api
1 parent cf0b6c8 commit 77f02af

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

Diff for: src/customer-resource.js

+8
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
import Resource from './resource';
2+
import defaultResolver from './default-resolver';
23
import handleCustomerMutation from './handle-customer-mutation';
34

45
// GraphQL
6+
import customerNodeQuery from './graphql/customerNodeQuery.graphql';
7+
58
import customerCreateMutation from './graphql/customerCreateMutation.graphql';
69

710
import customerAccessTokenCreateMutation from './graphql/customerAccessTokenCreateMutation.graphql';
@@ -28,6 +31,11 @@ import customerUpdateMutation from './graphql/customerUpdateMutation.graphql';
2831
* @class
2932
*/
3033
class CustomerResource extends Resource {
34+
fetch(customerAccessToken) {
35+
return this.graphQLClient
36+
.send(customerNodeQuery, {customerAccessToken})
37+
.then(defaultResolver('customer'))
38+
}
3139

3240
/**
3341
* Creates a customer.

Diff for: src/graphql/customerNodeQuery.graphql

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
query($customerAccessToken: String!) {
2+
customer(customerAccessToken: $customerAccessToken) {
3+
id
4+
firstName
5+
lastName
6+
attributes
7+
}
8+
}

0 commit comments

Comments
 (0)