No type field on the metafields created with productVariantCreate GraphQL API?

sillycube
Shopify Partner
693 16 101

I tried to create new variants & metafield with productVariantCreate  

 

 

query = f"""mutation productVariantCreate {{
      productVariantCreate(input: {{
          options: [\"1234", \"ABC\"],
          price: \"{price:.2f}\",
          inventoryPolicy: DENY,
          weight: {weight},
          weightUnit: {weight_unit},
          productId: \"gid://shopify/Product/{productId}\",
          inventoryQuantities: [{{
              locationId: \"{locationId}\",
              availableQuantity: {quantity}
          }}],
          metafields: [{{
              key: \"selectedVariants\",
              namespace: \"{SHOPIFY_METAFIELD_NAMESPACE}\",
              value: \"{str([(dict.get('variantID'), dict.get('quantity')) for dict in variant_dicts])}\",
              type: \"single_line_text_field\"
          }}]
      }}) {{
        product {{
          id
        }}
        productVariant {{
          id
        }}
        userErrors {{
          field
          message
        }}
      }}
    }}"""
    # print(f"{query = }")
    result = shopify.GraphQL().execute(query)

 

 

 After that, I try to check the metafield in my browser with this endpoint https://mystore.myshopify.com/admin/products/6635071438925/variants/39426605908045/metafields.json:

 

 

{
  "metafields": [
    {
      "id": 19331185868877,
      "namespace": "abc",
      "key": "selectedVariants",
      "value": "[(1626436894738, 1), (1626436927506, 1), (1626436861970, 1)]",
      "value_type": "string",
      "description": null,
      "owner_id": 39426605908045,
      "created_at": "2021-08-07T07:42:50-04:00",
      "updated_at": "2021-08-07T07:42:50-04:00",
      "owner_resource": "variant",
      "admin_graphql_api_id": "gid://shopify/Metafield/19331185868877"
    }
  ]
}

 

 

But I can't see the type on the metafield. And it's still using "string" as "value_type". What is happening?

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