Solved

"bulkOperationRunMutation is limited to one connection field" pratical example

DanubioBlu
Shopify Partner
13 0 4

 

In the doc there is the statement:

"The mutation that's passed into bulkOperationRunMutation is limited to one connection field, which is defined by the GraphQL Admin API schema."

 

What does it mean in practice?

Can I use it for example to generate products and variations at once with "productCreate" insider ? or i need to bulkOperationRunMutation split in two?

thanks

 

Accepted Solution (1)

ShopifyDevSup
Shopify Staff
1415 231 484

This is an accepted solution.

Hi @DanubioBlu 👋

 

These are connection fields for the `product` object. The limitation refers to having only one connection in this `mutation` argument passed in `bulkOperationRunMutation`. The input variables for the underlying mutation handles multiple connections, so you can create a product and its variants at the same time. For example, since both `variants` and `metafields` are connection fields:

 

This is invalid since 2 connections are returned as part of the mutation

 

mutation call($input: ProductInput!) {
    productCreate(input: $input) { 
        product {
            id
            variants {
                edges {
                    node {
                        id
                    }
                }
            }
            metafields (namespace:"custom"){
                edges {
                    node {
                        id
                    }
                }
            }
        }
    }
}

 

This is a valid since only 1 is returned

 

mutation call($input: ProductInput!) {
    productCreate(input: $input) { 
        product {
            id
            variants {
                edges {
                    node {
                        id
                    }
                }
            }
        }
    }
}

 

The inputs for this mutation can handle multiple connections like this

 

{
    "input": {
        "title": "foo",
        "options": ["bar"],
        "variants": [
            {
                "price": "111",
                "options": ["1"],
                "metafields": [{
                    "key": "foobar",
                    "namespace": "custom",
                    "type": "boolean",
                    "value": "true"
                }]
            },
            {
                "price": "222",
                "options": ["2"]
            }
        ],
        "metafields": [{
            "key": "foobar",
            "namespace": "custom",
            "type": "boolean",
            "value": "true"
        }]
    }
}

 

Hope that helps!

@Umiko 

Developer Support @ Shopify
- Was this reply helpful? Click Like to let us 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)

ShopifyDevSup
Shopify Staff
1415 231 484

This is an accepted solution.

Hi @DanubioBlu 👋

 

These are connection fields for the `product` object. The limitation refers to having only one connection in this `mutation` argument passed in `bulkOperationRunMutation`. The input variables for the underlying mutation handles multiple connections, so you can create a product and its variants at the same time. For example, since both `variants` and `metafields` are connection fields:

 

This is invalid since 2 connections are returned as part of the mutation

 

mutation call($input: ProductInput!) {
    productCreate(input: $input) { 
        product {
            id
            variants {
                edges {
                    node {
                        id
                    }
                }
            }
            metafields (namespace:"custom"){
                edges {
                    node {
                        id
                    }
                }
            }
        }
    }
}

 

This is a valid since only 1 is returned

 

mutation call($input: ProductInput!) {
    productCreate(input: $input) { 
        product {
            id
            variants {
                edges {
                    node {
                        id
                    }
                }
            }
        }
    }
}

 

The inputs for this mutation can handle multiple connections like this

 

{
    "input": {
        "title": "foo",
        "options": ["bar"],
        "variants": [
            {
                "price": "111",
                "options": ["1"],
                "metafields": [{
                    "key": "foobar",
                    "namespace": "custom",
                    "type": "boolean",
                    "value": "true"
                }]
            },
            {
                "price": "222",
                "options": ["2"]
            }
        ],
        "metafields": [{
            "key": "foobar",
            "namespace": "custom",
            "type": "boolean",
            "value": "true"
        }]
    }
}

 

Hope that helps!

@Umiko 

Developer Support @ Shopify
- Was this reply helpful? Click Like to let us 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