Lab - Query Practice
Customer Management
In this lab, you will:
- Register a customer
- Update a customer
- Add a customer address
- Update a customer address
- Delete a customer address
- Change a customer password
- Request a password reset
- Reset a password
Query Custom Form Fields
- Login to your store to access the control panel
- In the control panel, navigate to Settings > Storefront API Playground
- Copy and paste the following query into the playground
- Click the play button to submit the request
- View your response - GraphQL will return a list of form fields you have enabled in the storefront
Register a Customer
- Open a new tab for your Customer Registration Mutation
- Copy and paste the code below into the playground
- Enter the following in the GraphQL Variables section of the playground. You can change the customer name details to values for the customer you want to add. The values previously prepared when customer Form Fields were queried will be passed in for the various field entries; any value types for which you do not have corresponding fields will simply receive an empty array.
- Click the play button to submit the request
- View your response
- (Optional) Navigate to Control panel > Customers > View to see the newly registered customer
Log in a Customer
Before we move on to the next steps in the lab, you need to log in as the customer you just created.
- Open a new tab for your Customer Update Mutation
- Copy and paste the code below into the playground
- Enter the following in the GraphQL Variables section of the playground. Change the email and password values to those that belong to the customer.
- Click the play button to submit the request
- View your response
Update a Customer
This step will walk you through updating customer information with the GraphQL Storefront API. This is only for customer information (name, phone number, company, etc.), not for changing a password or updating an address.
- Open a new tab for your Customer Update Mutation
- Copy and paste the code below into the playground
- Enter the following in the GraphQL Variables section of the playground. You can change the details to values for the customer you want to update.
- Click the play button to submit the request
- View your response
Add a Customer Address
Customers can be associated with one or more addresses. This step will walk you through adding an address for an existing customer.
- Open a new tab for your new mutation
- Copy and paste the code below into the playground
- Enter the following in the GraphQL Variables section of the playground. You can change the details to values for the address you want to add.
- Click the play button to submit the request
- View your response
- Save the
entityIdfor the next lab step
Update a Customer Address
This step will walk you through updating a customer’s existing address.
- Open a new tab for your new mutation
- Copy and paste the code below into the playground
- Enter the following in the GraphQL Variables section of the playground. The
addressIdwill be theaddressEntityIdthat was returned in the previous step. You can change the details to values for the address you want to update.
- Click the play button to submit the request
- View your response
Delete a Customer Address
This step will walk you through deleting a customer’s address from their account.
- Open a new tab for your new mutation
- Copy and paste the code below into the playground
- Enter the following in the GraphQL Variables section of the playground. The
addressIdwill be theaddressEntityIdthat was used in the previous step.
- Click the play button to submit the request
- View your response
Change a Customer Password
This mutation can be used to change a customer’s password, but the user must know their password in order to successfully update their password.
- Copy and paste the code below into the playground
- Enter the following in the GraphQL Variables section of the playground. Change the current and new password values.
- Click the play button to submit the request
- View your response
Request a Password Reset
This step will walk you through requesting a password reset email.
- Copy and paste the code below into the playground
- Enter the following in the GraphQL Variables section of the playground. Change the customer’s email address.
- Click the play button to submit the request
- View your response
Reset a Password
This mutation is used to complete a password reset and you do not need to know the customer’s current password.
- Copy and paste the code below into the playground
- Enter the following in the GraphQL Variables section of the playground. Change the
customerEntityIdand the new password.
- Click the play button to submit the request
- View your response