GraphQL Error

masumluf
Tourist
35 0 3

Hello Developers, 

I have written below gql code but getting error . error is not clear, my code is, 

 

      const mailResponse = await client.query({
        data: `mutation customerPaymentMethodSendUpdateEmail(gid://shopify/CustomerPaymentMethod/${paymentId}: ID!) {
          customerPaymentMethodSendUpdateEmail(customerPaymentMethodId: $customerPaymentMethodId) {
            customer {
              # Customer fields
              id
              email
            }
            userErrors {
              field
              message
            }
          }
        }
        `,
      });

 

and error is 

 

┃ [{"message":"Parse error on \"gid\" (IDENTIFIER) at [1, 47]","locations":[{"line":1,"column":47}]}] mailResponse

 

 

Reply 1 (1)
toobiza
Shopify Partner
33 4 7

I think the issue is coming from the parsing of id parameter of the mutation. See this example here https://stackoverflow.com/questions/56090799/shopify-graphql-mutation-returns-parse-error-on-gid-ide...

 

i would recommend using the variables keyword defined within the query client see example here for node js. Note that the id is passed through the variable and not directly:

https://shopify.dev/api/admin-graphql/2022-04/mutations/customerDelete 

 

All the best!