Hi, There I'm new to Shopify GraphQl i want to create Product Variant for Pid:1617864523837, but I'm having an issue with uploading Options how can I set Option for a variant in graphQl , my option1 is color which is gold and option2 is a size which is 4 I want to set for this variant,I'm stuck here please give some solution so I can fix.Thanks
GRAPH QL QUERY FOR CREATING VARIANT
-----------------------------------------------------------------
mutation {
productVariantCreate(input: {productId: "gid://shopify/Product/1617864523837", title: "testVariant", options: "Gold,4"}) {
product {
id
}
productVariant {
title
}
userErrors {
field
message
}
}
}
ERROR
----------------------------------------------------------
{
"data": {
"productVariantCreate": {
"product": {
"id": "gid://shopify/Product/1617864523837"
},
"productVariant": null,
"userErrors": [
{
"field": null,
"message": "You need to add option values for Size"
}
]
}
},
"extensions": {
"cost": {
"requestedQueryCost": 12,
"actualQueryCost": 12,
"throttleStatus": {
"maximumAvailable": 1000,
"currentlyAvailable": 988,
"restoreRate": 50
}
}
}
}
Hi, After fiddling around i found this works ->
input: {productId: "gid://shopify/Product/1617864523837", title: "testVariant", options: [ "Gold,4" ]}
Try this and remove `,4` from it if it doesn't work the first time... also sending title attribute to productVariantCreate won't work as of version 2020-07. The value in the options field is taken. I do not have a clear idea about this too. the documentation is not so clear when it comes to GraphQL APIs.
Hope it helps !!
User | Count |
---|---|
28 | |
7 | |
7 | |
6 | |
5 |