Hello,
I’ve been working with the GraphQL Admin API (2025-01) for a few days. It’s honestly incredible, but there are some areas I’m struggling to find a lot of information on and LLMs aren’t much help here since the API is relatively new.
My goal is to programmatically create products, set their category and their attribute values according to the Shopify Standard Product Taxonomy (https://shopify.github.io/product-taxonomy/releases/unstable/).
I have gone as far as to create the product with the right category ID. At this stage I’m a bit confused how “Attributes” are defined. To my understanding Taxonomy Attributes are metafields (?) under the “shopify” namespace which I believe makes me unable to edit them directly by passing metafields to the productCreate mutation.
In general I feel like the while relationship between Metafield, Metaobject and MegaobjectDefinition is a bit unclear. It would be great if someone could point me to some documentation that clearly explains their relationship. Please also correct me if these metafields have nothing to do with Taxonomy Attributes.
Here is a small example of my query:
mutation createProduct($product: ProductCreateInput!, $media: [CreateMediaInput!]) {
productCreate(product: $product, media: $media) {
product {
...product
}
userErrors {
field
message
}
}
}
${productFragment}
And the variables:
{
product: {
status: "DRAFT",
category: "gid://shopify/TaxonomyCategory/fr-24-4",
title: "...",
descriptionHtml: "...",
vendor: "...",
productType: "Static",
tags: [
"b2b-import",
"Tables",
"Kitchen & Dining Room Tables",
],
metafields: [
{
namespace: "b2b",
key: "identification_code",
value: "FB98337.21",
type: "single_line_text_field",
},
{
namespace: "b2b",
key: "stockQuantity",
value: "156",
type: "number_integer",
},
{
namespace: "shopify",
key: "Leg color",
value: "[\"gid://shopify/TaxonomyValue/1\"]",
type: "list.metaobject_reference",
},
{
namespace: "shopify",
key: "Leg material",
value: "[\"gid://shopify/TaxonomyValue/21884\"]",
type: "list.metaobject_reference",
},
{
namespace: "shopify",
key: "Tabletop color",
value: "[\"gid://shopify/TaxonomyValue/7\"]",
type: "list.metaobject_reference",
},
{
namespace: "shopify",
key: "Tabletop material",
value: "[\"gid://shopify/TaxonomyValue/21862\",\"gid://shopify/TaxonomyValue/21899\"]",
type: "list.metaobject_reference",
},
],
},
}
I know I need to do some “prep-work” before being able to set those shopify TaxonomyValue fields but I’m not sure what.
Can someone please guide me or point me to some relevant documentation?
Please note again that I’m using GraphQL Admin API 2025-01 which is has differences compared to 2024 version.
Many thanks in advance!
Sorry for the not-so-relevant label on the post, but there were no labels for API or GraphQL.