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.

Issue with GraphQL mutation command in JSON format

Solved

Issue with GraphQL mutation command in JSON format

khossain
Excursionist
18 2 4

Dear Experts,

 

When I am sending GraphQL Mutation command as following JSON format it is shown following error, but when sending Query and Variable separately it is working good. Could you pls help what's wrong in the JSON format.

 

Variable $input of type ProductVariantInput! was provided invalid value

Payload as JSON:

{
"query":"mutation($input:ProductVariantInput!){productVariantUpdate(input:$input){productVariant{id sku inventoryItem {id sku}}}}"
,"variables":{
"id":"gid://shopify/ProductVariant/123456"
,"sku": null
}
}

 

The following Command executed successfully:

Query:

mutation ($input: ProductVariantInput!) {
    productVariantUpdate(input: $input) {
        productVariant {
            id
            sku
            inventoryItem {
                id
                sku
            }
        }
    }
}

 

Variable:

{
    "input": {
        "id": "gid://shopify/ProductVariant/123456",
        "sku": null

    }
}

 

Thank You,

Kamal Hossain

Accepted Solution (1)

khossain
Excursionist
18 2 4

This is an accepted solution.

I resolved it by adding Input object...it was missing in the variable

 

{
"query":"mutation($input: ProductVariantInput!){productVariantUpdate(input: $input){productVariant{id sku inventoryItem {id sku}}}}"
,"variables":{"input":{

"id":"gid://shopify/ProductVariant/32150580527153"
,"sku": null
}
}
}

 Thank you.

View solution in original post

Reply 1 (1)

khossain
Excursionist
18 2 4

This is an accepted solution.

I resolved it by adding Input object...it was missing in the variable

 

{
"query":"mutation($input: ProductVariantInput!){productVariantUpdate(input: $input){productVariant{id sku inventoryItem {id sku}}}}"
,"variables":{"input":{

"id":"gid://shopify/ProductVariant/32150580527153"
,"sku": null
}
}
}

 Thank you.