What's your biggest current challenge? Have your say in Community Polls along the right column.
Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

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

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

JeffSpurlock
Shopify Partner
11 0 15

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)