graphql customerUpdate mutation using node + fetch error

wb1
Shopify Partner
42 1 5

Can't figure out why I keep getting error on customerUpdate mutation . Can anyone spot the issue?

I've tried every permutation for the body that I can think of. I'm following this mutation: https://shopify.dev/api/examples/customer#update-a-customers-tags

 

{ errors: { query: 'Required parameter missing or invalid' } }

 

With code and node-fetch request library

 

const gql = `{
    customerUpdate(input: {id: "gid://shopify/Customer/${customerId}", tags: "${tags.join(', ')}"}) {
      customer {
        tags
      }
    }
  }`

  const uri = `https://${shop}/admin/api/2021-07/graphql.json`

  const options = {
    method: 'POST',
    headers: {
      'X-Shopify-Access-Token': accessToken,
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      mutation: gql
    })
  }
  fetch(uri, options)

 

 

Replies 2 (2)
awwdam
Shopify Staff
172 32 17

Hey @wb1,

While there were no specific details shared around the values you are passing with this request (the raw request), the only thing that stood out formatting wise would be the lack of operation in the request, eg: const gql = ` mutation{customerUpdate(input: ... If you are using our shopify-node-api library, I would suggest looking through the documentation that includes GraphQL request examples to work with. That said, if you you be able to share an x-request-id response header that is returned with this error, I can take a closer look at logs on our end and pass back any potential insights. 

Cheers!

awwdam | API Support @ Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

awwdam
Shopify Staff
172 32 17

Hey @wb1,

I also wanted ask if you tested the mutation and variables with using an API client (such as Insomnia) to confirm functionality. Please also let me know if this is successful!
 

awwdam | API Support @ Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog