Why is my bulkOperationRunMutation not functioning?

Hi all,

I am having a bit of trouble with the bulkOperationRunMutation part of the tutorial: https://shopify.dev/api/usage/bulk-operations/imports

I am attemping to send the “productAppendImages” mutation through the GraphiQL App in my dev store:

mutation bulkOperationRunMutation
($mutation: String!, $stagedUploadPath: String!) {
  bulkOperationRunMutation
  (mutation: "mutation productAppendImages($input: ProductAppendImagesInput!) {productAppendImages(input: $input) {newImages {id alt Text}product {id} userErrors {field message}}}", 
    stagedUploadPath: "tmp/984219684/bulk/4cd8a192-793c-40d5-ae0a-51f259d66f78/bulk_op_vars") {
    bulkOperation {
      id
    }
    userErrors {
      field
      message
    }
  }
}

The JSONL file that is being used to generated my stagedUploadPath looks like so :

{"input":{"id":"gid://shopify/Product/6667734024228", "images":[{"altText":"Jack-jeans 527", "src":"http://web.demo.com/media/default/11300-527_l1.jpg"}]}}\n

The GraphiQL App is responding with :

{
  "message": "The server responded with invalid JSON, this is probably a server-side error",
  "response": ""
}

Has anyone encountered this problem before? Any pointers would be gratefully accepted :slightly_smiling_face:

Cheers,

Matthias

Update:

I changed how I was saving my .jsonl file to my array in order to pass it as a multiform to (in my case) AWS s3.

Previously I was just calling :

$generatecurl['file'] = __DIR__.'/graphqldemocalls/calls.jsonl';

To add the file at the end of my multiform however, calling it like so allowed me to get a “Completed” status from the GraphiQLApp.

$generatecurl['file'] = file_get_contents(__DIR__.'/graphqldemocalls/calls.jsonl');

When attempting to find the status of my bulkrequest with the “currentBulkOperation” graphQL query I am greeted with this response:

{
  "data": {
    "currentBulkOperation": {
      "id": "gid://shopify/BulkOperation/{{BulkOperationID}}",
      "type": "MUTATION",
      "status": "FAILED"
      "errorCode": "INTERNAL_SERVER_ERROR"
    }
  },
  "extensions": {
    "cost": {
      "requestedQueryCost": 1,
      "actualQueryCost": 1,
      "throttleStatus": {
        "maximumAvailable": 2000,
        "currentlyAvailable": 1999,
        "restoreRate": 100
      }
    }
  }
}

So it’s moving along but still confused as to why the BulkOperation is being accepted but not completeing. :s

Cheers,
Matthias

Update:

I have come to the hopefully correct conclusion that the reason my Bulk Operation returns “CANCELLED” status is because if I run the mutation :

mutation {
  bulkOperationRunMutation(
    mutation: "mutation call($input: ProductAppendImagesInput!) {productAppendImages(input: $input) {newImages {altText}product {id} userErrors {field message}}}",
    stagedUploadPath: "tmp/gcs/984219684/bulk/{{temp}}/bulk_op_vars") {
    bulkOperation {
      id
      status
      objectCount
      fileSize
    }
    userErrors {
      field
      message
    }
  }
}

I receive a response with the “objectCount” : “0”, “fileSize”: null and therefore my jsonl is not being parsed/received correctly leading to the Bulk Operation to be cancelled.

I hope I am on the right track and appreciate any pointers :slightly_smiling_face:

Cheers,

Matthias

Update :

It is now working :slightly_smiling_face: however, I had to have the entire process be completed programmatically. Previously, I was generating the stageduploads URL programmatically and then copy pasting the bucket’s key into the GraphiQL App and running the query.

However, I am not too sure if the GraphiQL App is designed for mutations let alone bulk mutations, but I don’t know.

I plan to write a mini guide/wrap-up of all the things that caught me off guard and hopefully help speed up someone elses development :slightly_smiling_face:

Cheers,

Matthias

Hey Matthias, would be happy to hear if you made any progress on this since you last wrote :slightly_smiling_face:
I’m facing a similar issue, only with productCreate instead of productAppendImages

Hey Gabby,

I am pleased to say that yes, I was able to get it all running as it should, am now trying to get the Webhook Subscription to work haha, but which part exactly are you stuck on?
Are you trying to get a response from AWS/Google, are you trying to use the key returned from AWS/google?
Cheers,

Matthias

Hey Matthias, thanks for your quick response :slightly_smiling_face:
Ended up figuring that section out as well, thanks!
Will update with future progress on Webhook subscription.
Anything special I need to know ?
Thanks, cheers :slightly_smiling_face:

Hey Gabby,

Nice :slightly_smiling_face: congratulations on the progress, well it was weekend so, today I am starting work on the webhook subscriptions, at the moment no, I have no tips or insights to give you should that change I’ll write here.

Cheers,

matthias