How to fix an invalid id error when updating products using graphql?

Hi,

I’m trying to update products using the graphql endpoint,

It is working as expected in the Grphiql App, but not in my node app.

Here is the query :

mutation productUpdate ($input1: ProductInput!) {
    productUpdate (input: $input1) {
        product {
            id
            handle
            metafield(key: "front", namespace: "linked_products") {
                id
            }
        }
        userErrors {
            field
            message
        }
    }
}

& the input :

{
  "input":{
    "id":"gid://shopify/Product/65522031xxxxxxx"
  }
}

The error message I’m getting is :

Error: [{"message":"invalid id","locations":[{"line":3,"column":21}],"path":["productUpdate"]}] {stack: 'Error: [{"message":"invalid id","locations":[line":3,"column":21}],"path":["productUpdate"]}]', message: '[{"message":"invalid id","locations":[{"line":3,"column":21}],"path":["productUpdate"]}]'}

This has really taken so much debug time, really obscure !

Solved.

The GID of a product variant should be : productVariant & not Variant