Manage customer data with the GraphQL Admin API
The following are example GraphQL queries and mutations for working with customers.
Querying customers
Anchor link to section titled "Querying customers"For more information on querying customers, see the customer object reference.
Get a customer's name, email, and default address
Anchor link to section titled "Get a customer's name, email, and default address"Query: POST /admin/api/2022-04/graphql.json
View response
Get the first five line items of the customer's last order
Anchor link to section titled "Get the first five line items of the customer's last order"Query: POST /admin/api/2022-04/graphql.json
View response
Get two specific customers by their ID using aliases
Anchor link to section titled "Get two specific customers by their ID using aliases"Query: POST /admin/api/2022-04/graphql.json
View response
Get the display name and total spent of the first five customers with more than three orders
Anchor link to section titled "Get the display name and total spent of the first five customers with more than three orders"Query: POST /admin/api/2022-04/graphql.json
View response
Get the email, name, and account creation date of three customers using a fragment
Anchor link to section titled "Get the email, name, and account creation date of three customers using a fragment"Query: POST /admin/api/2022-04/graphql.json
View response
Get all customers in Canada
Anchor link to section titled "Get all customers in Canada"Query: POST /admin/api/2022-04/graphql.json
View response
Get all a customer's fields and connections
Anchor link to section titled "Get all a customer's fields and connections"Query: POST /admin/api/2022-04/graphql.json
View response
Query: POST /admin/api/2022-04/graphql.json
Creating customers
Anchor link to section titled "Creating customers"For more information, see the customerCreate mutation reference.
Create a customer and return their customer ID
Anchor link to section titled "Create a customer and return their customer ID"Query: POST /admin/api/2022-04/graphql.json
View response
Create a customer with a metafield
Anchor link to section titled "Create a customer with a metafield"
Variables
View response
Query: POST /admin/api/2022-04/graphql.json
Updating customers
Anchor link to section titled "Updating customers"For more information, see the customerUpdate mutation reference.
Update a customer's first name and return their customer ID
Anchor link to section titled "Update a customer's first name and return their customer ID"
View response
Query: POST /admin/api/2022-04/graphql.json
Update a customer's tags
Anchor link to section titled "Update a customer's tags"Query: POST /admin/api/2022-04/graphql.json
View response
Deleting customers
Anchor link to section titled "Deleting customers"For more information, see the customerDelete mutation reference.
Delete a customer and return their ID
Anchor link to section titled "Delete a customer and return their ID"Query: POST /admin/api/2022-04/graphql.json
View response