React Apollo perform GraphQL bulk operation

Highlighted
Shopify Partner
7 0 0

I am trying to do a bulk operation following this guide, however, it is not clear for me how to do it using react apollo: to start the bulk operation, I am using the useMutation hook, which should return an object like this:

{
  "data": {
    "bulkOperationRunQuery": {
      "bulkOperation": {
        "id": "gid://shopify/BulkOperation/155691024464",
        "status": "CREATED"
      },
      "userErrors": []
    }
  },
  "extensions": {
    "cost": {
      "requestedQueryCost": 10,
      "actualQueryCost": 10,
      "throttleStatus": {
        "maximumAvailable": 1000,
        "currentlyAvailable": 990,
        "restoreRate": 50
      }
    }
  }
}

Which I would then poll until the status changes to COMPLETED. However, when I create the bulk operation using the hooks if I log to the console the result I just get a log of the Apollo client object: {called: false, loading: false, client: DefaultClient}

What am I doing wrong?

0 Likes