Join us for an upcoming Shopify Partner webinar on February 27, 2024. Discover the latest Checkout Extensibility features, and deep dive on improvements to Shopify Functions and Web Pixels. Register now for either the 10am EST or 2pm EST sessions.

React Apollo perform GraphQL bulk operation

robsanna
Shopify Partner
7 0 1

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?

Reply 1 (1)

ArabyCode
Visitor
2 0 1

Have you found a solution to this ?

my code is just returning 

TypeError: Cannot read property 'data' of undefined