shopifyshopify-api

Shopify, bulk operations and metaobjects


I'm trying to run a bulk query on Shopify, leveraring bulkOperationRunQuery:

https://shopify.dev/docs/api/admin-graphql/2024-01/mutations/bulkOperationRunQuery

My problem is that I want to query metaobjects, and I don't find how to use bulkOperationRunQuery with such queries.

Here is below an example of a query I'd like to send in bulk, for instance if I try to get the identifier field of my 5000 cars:

query Metaobjects {
    metaobjects(type: "car") {
        nodes {
            field(key: "identifier") {
                key
                value
            }
        }
    }
}

The query works like that, but I don't know how to feed bulkOperationRunQuery with this query.

I followed this documentation, replacing the query example by mine, but can't make it work: https://shopify.dev/docs/api/usage/bulk-operations/queries#write-a-bulk-operation

In fact, I wonder if bulkOperationRunQuery can accept metaobjects queries...


Solution

  • Original

    The reference needs to have subsection { __typename }

    Bulk query must be able to run this. There isn't a hard-no for this type.

    Updated after post update

    Fine tuned the query to match the bulk query format. What I observed was it required edges and replaced the nodes with node. Could you confirm me if this runs for you? My current store doesn't have permissions to query these.

    mutation {
      bulkOperationRunQuery(
        query: """
            {
              metaobjects(type: "car") {
                edges {
                  node {
                    field(key: "identifier") {
                      key
                      value
                    }
                  }
                }
              }
            }
        """
      ) {
        bulkOperation {
          id
          status
        }
        userErrors {
          field
          message
        }
      }
    }
    

    Successful run enter image description here Here's a snapshot of Bulk request being created and its status. ( Yeah I know access is not there but this is my testing account. )