Shopify GraphQL customerCreate mutation requires password?

Shopify GraphQL customerCreate mutation requires password?

olansgz
Visitor
1 0 1

I am using Shopify's GraphQL mutations in order to create a customer on a button click on the front end of my website. The user is prompted for an email, on submit, they will receive an email to activate their account. The "customerCreate" mutation in the documentation does not state that password is required, however my API response states that a password is required in my post request, can anyone help me to create an account without requiring a password? Here is the shopify documentation . Thank you in advance for any help

mutation customerCreate($input: CustomerCreateInput!) {
      customerCreate(input: $input) {
        customerUserErrors {
          code
          field
          message
        }
        customer {
          id
        }
      }
    }


    {
      "input": {
        "email": "example@gmail.com",
        "acceptsMarketing": true
      }
    }

Error message: "message": "Variable $input of type CustomerCreateInput! was provided invalid value for password (Expected value to not be null)",

Reply 1 (1)

SocialAutoPost
Shopify Partner
434 59 105

Hi @olansgz,

 

In the Shopify GraphQL API, it is possible to create a customer without requiring a password by omitting the password field in the input object of the customerCreate mutation. The customerCreate mutation allows you to specify a number of optional fields in addition to the required email field, but the password field is not one of them.

 

Therefore, you can simply leave out the password field in your GraphQL request, and Shopify will create the customer without requiring a password.

 

Here is an example of a GraphQL request that creates a customer without requiring a password:

 

 

mutation {
  customerCreate(input: {
    email: "example@gmail.com",
    acceptsMarketing: true
  }) {
    customerUserErrors {
      code
      field
      message
    }
    customer {
      id
    }
  }
}

 

 

Note that if you do not specify a password, the customer will not be able to log in to their account until they set a password.

 

I hope this helps! Let me know if you have any questions or if there is anything else I can assist you with.

 

Was the reply helpful? Click Like to let me know!
Was your question answered? Mark it as an Accepted Solution
Auto post your Shopify products to Instagram, Facebook, Pinterest, LinkedIn and Twitter.
App: Social Schedular