Skip to content

Commit

Permalink
add customer.fetch api
Browse files Browse the repository at this point in the history
  • Loading branch information
isamu committed Jul 3, 2021
1 parent cf0b6c8 commit 26ba75a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/customer-resource.js
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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.
Expand Down
7 changes: 7 additions & 0 deletions src/graphql/customerNodeQuery.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
query($customerAccessToken: String!) {
customer(customerAccessToken: $customerAccessToken) {
id
firstName
lastName
}
}

0 comments on commit 26ba75a

Please sign in to comment.