productCreate GQL mutation issue: valueType scheme check for metafields.

HunkyBill
Shopify Expert
4374 36 468

So you can create metafields to stuff right in a product at create time. And it works. But on using 2020-07 to build some products I am running into a problem.

 

If I set the valueType of a metafield to INTEGER, I feel like I should be able to set the value to some integer like 4663 or 11017 but instead, I get a GQL error saying cannot coerce 4663 to string.

 

So to shut that down I just added a to_s to my integer and it all worked, so I get an integer metafield value of 4663 but that seems buggy and wrong to me. Can someone at Shopify please confirm you have your wiring correct on schema for valueType. Seems off to me.

Custom Shopify Apps built just for you! hunkybill@gmail.com http://www.resistorsoftware.com
0 Likes
Greg_Kujawa
Shopify Partner
965 80 205

Reading the API docs, although the valueType is INTEGER, the value appears to still be passed as a quoted string --> https://shopify.dev/tutorials/manage-metafields-with-graphql-admin-api. Which makes no sense really! 

HunkyBill
Shopify Expert
4374 36 468

I guess that was my long-winded message. Thanks for the backup!

Custom Shopify Apps built just for you! hunkybill@gmail.com http://www.resistorsoftware.com
Greg_Kujawa
Shopify Partner
965 80 205

Apparently the roots of Shopify appear to be based in Ruby/Liquid. Ironic, since there are some back alleys of the API that clearly break Matz' principle of least astonishment. Lol.

0 Likes