Unable to get metafields and variants information after uploading the product using bulk mutation


mutation {
  bulkOperationRunMutation(
    mutation: "mutation productCreate($input: ProductInput!) {
                  productCreate(input: $input) {
                    product {
                      id
                      handle
                      variants(first:10){edges{node{id sku }}}
                      metafields(first:10){edges{node{id key}}}
                    }
                    userErrors {
                      field
                      message
                    }
                  }
                }",
    stagedUploadPath:"%s") {
    bulkOperation {
      id
      url
      status
    }
    userErrors {
      message
      field
    }
  }
}

While running the above mutation I am getting following error:
‘userErrors’: [{‘message’: ‘Bulk mutations cannot contain more than 1 connection.’, ‘field’: [‘mutation’]}]

I got what error tries to explain but How can I resolve this issue so that I can get both metafields and variants id in response.

Hi @nayantaraSingh

I see two options:

  1. Use aliases for each of the metafield ids you need back. For example:
size: metafield(namespace: "custom", key: "size") { id }
capacity: metafield(namespace: "custom", key: "capacity") { id }
  1. Pick the connection that is more important and make a follow up API call for to retrieve the ids.
1 Like

But this way i will only get products and metafields information and will have to make separate call for getting the variants details.

Can I somehow get the product, metafields and variants details in response?
Because I am able to upload everything using productCreate in bulk but not able to get the details of everything in response.