Dedicated to the Hydrogen framework, headless commerce, and building custom storefronts using the Storefront API.
Hey, I want to create a customer with password using the graphql api. I followed the documentation to create a customer with password to avoid the activation process by email, this is the query I'm sending:
mutation { customerCreate( input: { firstName: "dave", lastName: "smith", email: "[email protected]", password: "12345" acceptsMarketing: true, } ) { customer { id firstName lastName email } userErrors { field message } customer { id } } }
But I'm getting this error as if the specification changed:
{ "errors": [ { "message": "InputObject 'CustomerInput' doesn't accept argument 'password'", "locations": [ { "line": 7, "column": 11 } ], "path": [ "mutation", "customerCreate", "input", "password" ], "extensions": { "code": "argumentNotAccepted", "name": "CustomerInput", "typeName": "InputObject", "argumentName": "password" } } ] }
How do I do to achieve this? Thanks!
Solved! Go to the solution
This is an accepted solution.
Hey there,
You might be seeing this error because your request is targeting the GraphQL Admin API and not the Storefront API. I would take a look at this guide which outlines the steps you need to follow.
Namely, you need to be using the proper GraphQL endpoint - `POST https://my-store-name.myshopify.com/api/graphql` and you need to provide the `X-Shopify-Storefront-Access-Token` header with your Storefront Access Token which is different from your Admin Access Token.
To learn more visit the Shopify Help Center or the Community Blog.
This is an accepted solution.
Hey there,
You might be seeing this error because your request is targeting the GraphQL Admin API and not the Storefront API. I would take a look at this guide which outlines the steps you need to follow.
Namely, you need to be using the proper GraphQL endpoint - `POST https://my-store-name.myshopify.com/api/graphql` and you need to provide the `X-Shopify-Storefront-Access-Token` header with your Storefront Access Token which is different from your Admin Access Token.
To learn more visit the Shopify Help Center or the Community Blog.
Thanks!
I realize this thread is a bit old and marked as "Solved", but it's worth mentioning that not supporting a password field from the Admin API is a real issue. It doesn't make sense that the only way you can create an account with a password is with the Storefront API. There are other fields (e.g. locale) in the Admin API that we require anyway, so we'd have to use a combination of both. It looks like for now we might have to use a combo of the REST and GraphQL Admin API.