How to update product options in product variant in Shopify?

pankajyadav
New Member
2 0 0

We are facing challenges while updating product options in product variants as options fields in GraphQL and Rest API are totally different. Below is the screen-shot:

GraphQL: enter image description here

REST APIs: enter image description here

We are using GraphQL to mutate product variant. So our challenge is, how can we send three different options (like, large, blue, paper) to product variant that make one variant as it takes only one [String!] value. Whereas in REST APIs, there are three different options (option1, option2, option3) along with Default Title.

 

Also, if possible can anyone share a dummy mutation request for this?

 

Below are the links that we are referring to:

Update Product Variant: https://shopify.dev/docs/admin-api/graphql/reference/mutation/productvariantupdate?api[version]=2020...

Update Product: https://shopify.dev/docs/admin-api/graphql/reference/mutation/productupdate?api[version]=2020-04

0 Likes
Max_Sadlowski
Shopify Expert
64 1 27

@pankajyadav Did you ever find a solution for this or good examples? 

Max Sadlowski - CEO - BentoSMB - Shopify Expert
0 Likes
iozyigit
Tourist
3 0 1

@Max_Sadlowski , check this, just saw this solution.

Hope Shopify would have better documentation

https://community.shopify.com/c/Shopify-APIs-SDKs/Solved-GraphQL-Product-Create-with-Variant-Options...

 

Max_Sadlowski
Shopify Expert
64 1 27

thanks @iozyigit after staring at the documentation for about an hour I realized the string was surrounded in square brackets. It's still quite a pain as the query results and the mutation input are different set ups, not sure why they didn't have consistency across those two spots. 

Max Sadlowski - CEO - BentoSMB - Shopify Expert
0 Likes