Join us for an upcoming Shopify Partner webinar on February 27, 2024. Discover the latest Checkout Extensibility features, and deep dive on improvements to Shopify Functions and Web Pixels. Register now for either the 10am EST or 2pm EST sessions.

customerCreate mutation returning no errors, but isn't creating the customer

JeffSpurlock
Shopify Partner
9 0 10

Hello,

 

I have this function:

 

 

async function customerCreate(email: string, fName: string, lName: string){
  const createCustomerInput = {
        "email": email,
        "firstName": fName,
        "lastName": lName,
        "tags": [
          "{REDACTED}"
        ]
    }
  const createCustomerQuery = `
    mutation customerCreate($input: CustomerInput!) {
      customerCreate(input: $input) {
        customer {
          id
        }
        userErrors {
          field
          message
        }
      }
    }`
  const {data, errors, extensions} = await client.request(createCustomerQuery, {
    variables: {
      input: createCustomerInput
    }
  })
  let obj = {
    data,
    errors,
    extensions
  }
  return obj
}

 

 

const newCustomer = await customerCreate("test@test.com", "John", "Doe")
console.log(newCustomer.data)

 

 

and then the response is 

 

 

{ customerCreate: { customer: null, userErrors: [ [Object] ] } }

 

 

I don't understand why the customer is coming back null. Also, if log the userErrors property, it says undefined, and if i log the response.errors property, it also shows undefined. So i'm not getting any errors, but it's clearly not working. 

 

Any ideas?

 

Replies 0 (0)