Problems when getting status of bulk operation

Hello,

I’m currently experimenting with bulk operations to perform multiple mutations while having less API calls. My operations are being executed and perform the correct actions (as far as I can tell).

Problem

I’m unable to get/check the status of my bulk operations.
Here is my workflow:

Upload the file for my mutation

mutation ($input: [StagedUploadInput!]!) {
    stagedUploadsCreate(input: $input) {
        userErrors {
            field
            message
        }
        stagedTargets {
            url
            resourceUrl
            parameters {
                name
                value
            }
        }
    }
}
//$input
const uploadInput: StagedUploadInput = {
    filename: "credits.json", httpMethod: "POST", mimeType: "text/jsonl", resource: "BULK_MUTATION_VARIABLES"
};

Notes

The upload request was send and the my file with metafield mutations is uploaded to the Shopify S3 Storage. Those two requests return a 2XX status code.

Starting the bulk operation

mutation ($mutation: String!, $stagedUploadPath: String!) {
    bulkOperationRunMutation(
        mutation: $mutation,
        stagedUploadPath: $stagedUploadPath) {
        bulkOperation {
            id
            url
            status
        }
        userErrors {
            message
            field
        }
    }
}

$stagedUploadPath is the path provided by the stagedUploadsCreate Mutation and $mutation is a mutation that updates metafields of dummy customers.

Response

{"data":{"bulkOperationRunMutation":{"bulkOperation":{"id":"gid://shopify/BulkOperation/6174703812940","url":null,"status":"CREATED"},"userErrors":[]}},"extensions":{"cost":{"requestedQueryCost":10,"actualQueryCost":10,"throttleStatus":{"maximumAvailable":2000.0,"currentlyAvailable":1990,"restoreRate":100.0}}}}

Notes

The API returns no errors, so I guess my input was correct. After checking the dummy customers, the metafields are edited correctly, so the bulk operation is being executed and should finish successfully.

Checking the operation status

query single {
    node(id: "gid://shopify/BulkOperation/6174703812940") {
        ... on BulkOperation {
            url
            partialDataUrl
            completedAt
            errorCode
            id
        }
    }
}

Response

{
    "data": {
        "node": null
    },
    "extensions": {
        "cost": {
            "requestedQueryCost": 1,
            "actualQueryCost": 1,
            "throttleStatus": {
                "maximumAvailable": 2000,
                "currentlyAvailable": 1999,
                "restoreRate": 100
            }
        }
    }
}

Notes

My expectation was to get the fields I requested and not null.


Let me know if you need further information. I appreciate any help!

Could you try the current bulk operation? :thinking:

Unfortunately, this also only returns null in any case.

Request

query get {
    currentBulkOperation(type: MUTATION) {
        id
        status
        errorCode
        createdAt
        completedAt
        objectCount
        fileSize
        url
        partialDataUrl
    }
}

Response

{
    "data": {
        "currentBulkOperation": null
    },
    "extensions": {
        "cost": {
            "requestedQueryCost": 1,
            "actualQueryCost": 1,
            "throttleStatus": {
                "maximumAvailable": 2000,
                "currentlyAvailable": 1999,
                "restoreRate": 100
            }
        }
    }
}

Oh I’ve just checked and realised you are trying to do a staged uploads as part of a bulk operation. That’s not supported and likely the reason why.

Please see the docs on how to use and what mutations are supported Bulk import data with the GraphQL Admin API

You can call staged uploads with up to 250 uploads in one go if you need to do multiple :blush:

I’m not quite sure if I understand this correctly. To run a bulk mutation, I have to do a staged upload so the bulk mutation has data to process, right? So procedure would be:

  1. call stagedUploadsCreate Mutation
  2. POST request to upload JSONL
  3. call bulkOperationRunMutation Mutation
  4. Wait till bulk mutation is finished (webhook/query)

If that’s correct, I’m sorry but I don’t quite understand my mistake. This is how I have always proceeded up to now. After all, I also receive the response that the bulk mutation has been created (with ID) and see it is making changes in the store.

Ohhh I see what you mean you are correct sorry, shouldn’t try read code on my phone. :see_no_evil_monkey:

Do you have an example of your jsonl file and the inputs to the bulk operation?

Sure

This is set as $mutation in my bulkOperationRunMutation.

mutation updateCustomerMetafields($input: CustomerInput!) {
    customerUpdate(input: $input) {
        userErrors {
            field
            message
        }
    }
}

For testing, I only use one line in my JSONL file.

{"input":{"metafields":[{"value":"{\"amount\":\"123.00\",\"currency_code\":\"EUR\"}","namespace":"lgg","key":"credit"},{"value":"2025-03-25T10:08:20.804Z","namespace":"lgg","key":"credit_changed"}],"id":"gid://shopify/Customer/8128253067596"}}

Thanks, that looks okay to me.
What was your staged uploads path?

The file was uploaded to
https://shopify-staged-uploads.storage.googleapis.com/tmp/82908610892/bulk/6779b805-69a8-4444-a517-bf361e622856/credits.jsonl

Ah okay. That all looks good.

Oh when you were trying to check on the bulk operation, were you doing it from your own app with its credentials or from the iGraphQL App?
Bulk operations are scoped to each app, so you can’t check on it from a different app

Thank you very much. I didn’t even notice that.

I started the bulk mutation via Google Apps Script and checked the status via Postman, that’s why only null was returned

1 Like