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.

Why is the grams field of product variant missed in Graphql API?

Why is the grams field of product variant missed in Graphql API?

jam_chan
Shopify Partner
938 24 193

I am trying to migrate a part of my REST API to GraphQL API. In particular, I try to sum different variants' weight. I can use the grams in the REST API but the field is missed in the GraphQL API. Why is it a difference?

BYOB - Build Your Own Bundles, SPO - SEO App to research keywords & edit social link preview
Replies 2 (2)

Jason
Shopify Partner
11207 226 2319

They are different APIs so whilst there is similarities, there will be differences. GraphQL does has weight and weight unit properties that you can use to achieve the same result.

 

Is there an issue pulling the data from a different place?

★ I jump on these forums in my free time to help and share some insights. Not looking to be hired, and not looking for work. http://freakdesign.com.au ★
jam_chan
Shopify Partner
938 24 193

Thanks for your prompt reply. 

 

I am trying to combine several variants into 1 new variant. The new variant is created by my app. So I was using the grams field to calculate the total weight. After that, convert the total weight in g to another weight unit for variant creation. 

 

Now the grams field is missed and it's getting a bit difficult. I try to do the unit conversion between 'g', 'kg', 'lb', 'oz' on my own. Still works but is easier to trigger a calculation error. 

BYOB - Build Your Own Bundles, SPO - SEO App to research keywords & edit social link preview