MetafieldsSet query as bulk operation/mutation

Solved
SilasGrygier
Shopify Partner
19 2 4

Is the metafieldsSet query available as a bulk query? The documentation for bulk import is unclear as to whether or not you can create metafields using bulk queries. The metafieldsSet query is listed as a bulk mutation under the Limitations header of the docs but a little bit further down under the section Create a bulk mutation it only mentions product & collection mutations, if someone could clarify this it would be highly appreciated.

 

I have read that it's possible to bulk create/update metafields using the productUpdate mutation but this seems more cumbersome because you have to include the metafield id which I want to avoid by using the metafieldsSet query if that is somehow possible. 

 

 

 

 

Accepted Solution (1)
Umiko
Shopify Staff
Shopify Staff
42 8 13

This is an accepted solution.

Hi @SilasGrygier 👋

 

The  `metafieldsSet` mutation is supported as a bulk operation with `bulkOperationRunMutation`. You should be able to pass the below in a string format, as the `mutation` argument. Keep in mind that the uploaded JSONL file will need to contain `MetafieldSetInput` objects as well.

 

mutation call($metafields: [MetafieldsSetInput!]!) {
    metafieldsSet(metafields: $metafields) {
        metafields {
            key
            namespace
            value
            createdAt
            updatedAt
        }
    }
}

 

Hope that helps!

Umiko | API Support @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

View solution in original post

Reply 1 (1)
Umiko
Shopify Staff
Shopify Staff
42 8 13

This is an accepted solution.

Hi @SilasGrygier 👋

 

The  `metafieldsSet` mutation is supported as a bulk operation with `bulkOperationRunMutation`. You should be able to pass the below in a string format, as the `mutation` argument. Keep in mind that the uploaded JSONL file will need to contain `MetafieldSetInput` objects as well.

 

mutation call($metafields: [MetafieldsSetInput!]!) {
    metafieldsSet(metafields: $metafields) {
        metafields {
            key
            namespace
            value
            createdAt
            updatedAt
        }
    }
}

 

Hope that helps!

Umiko | API Support @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog