Unable to Perform bulk operations with the GraphQL Admin API

technologytest
Tourist
3 0 1

In the GraphiQL app, I'm able to successfully create a new mutation with bulkOperationRunQuery, as well as successfully create a subscription to a webhook topic for that bulk operation. However, I am having difficulty executing these bulk operations in my public app code in order to gain access to the GraphQL response via subscribing to a webhook.

 

I have referred to the bulk operation documents below, and I have also tested this using the 10-21 API so that I can subscribe to the topic of 'BULK_OPERATIONS_FINISH'. I have also tried the current API version with a separate topic.

https://shopify.dev/api/usage/bulk-operations/queries

 

Using my existing code below as a point of reference, am I missing something in my syntax that is not allowing me to properly create a bulk operation and subscribe to a webhook for that bulk operation to eventually be downloaded / used in my public app?

 

Any feedback would be helpful - thank you.

import React from "react";
import gql from "graphql-tag";
import { useMutation } from "react-apollo";


const firstQ = gql`
mutation {
  bulkOperationRunQuery(
   query: """
    {
      products {
        edges {
          node {
            id
            title
          }
        }
      }
    }
    """
  ) {
    bulkOperation {
      id
      status
    }
    userErrors {
      field
      message
    }
  }
}
`;


function BulkQuery() {

    const { data, loading, error } = useMutation(firstQ); 
    if(loading) return null;
    if(error) return null;

    console.log(data);
    console.log(JSON.stringify(data));

    return(
        <div>Test Request</div>
    );  
}

const hookSub = gql`
    mutation {
    webhookSubscriptionCreate(
        topic: BULK_OPERATIONS_FINISH
        webhookSubscription: {
        format: JSON,
        callbackUrl: "https://12345.ngrok.io/"}
    ) {
        userErrors {
        field
        message
        }
        webhookSubscription {
        id
        }
    }
    }
`;


function BulkSubscription() {
    const { data, loading, error } = useMutation(hookSub);  
    if(loading) return null;
    if(error) return null;

    console.log(data);
    console.log(JSON.stringify(data));
    return(
        <div>Test Subscription</div>
    );  
}


const Queries = () => {
    return(
        <div>
            <BulkQuery/>
            <BulkSubscription/>
        </div>
        
    )
}

export default Queries;

 

0 Likes