Have your say in Community Polls: What was/is your greatest motivation to start your own business?
Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

Graphql Bulk Operation on resources without queries

Graphql Bulk Operation on resources without queries

it-jkboots
Shopify Partner
8 0 1

I am needing to do a bulk operation query on Fulfillments, which doesn't have a relevant query. There are two ways I can think to go about this, though I have gotten neither to work.

 

First, subqueries:

 

mutation {
    bulkOperationRunQuery(
        query: """{
    fulfillmentOrders(query: "fulfillments.id:gid://shopify/Fulfillment/5198645887174 OR fulfillments.id:gid://shopify/Fulfillment/5198645887175 ORfulfillments.id:manyMoreIds", includeClosed: true) {
		edges {
			node {
				id
				fulfillments {
					edges {
						node {
							id
							moreFields
						}
					}
				}
			}
		}
	}
}"""
    ) {
        bulkOperation {
            id
            createdAt
            completedAt
            errorCode
            objectCount
            partialDataUrl
            type
            status
            url
        }
        userErrors {
            field
            message
        }
    }
}

When I run this, it simply pretends the query on the fulfillmentOrders doesn't exist.

 

 

Second, bulk operation on nodes:

 

mutation {
    bulkOperationRunQuery(
        query: """{
	nodes(
		ids: [
			"gid://shopify/Fulfillment/1234567891234"
			"gid://shopify/Fulfillment/1234567891235"
			"gid://shopify/Fulfillment/1234567891236"
			"gid://shopify/Fulfillment/1234567891237"
			1000 more ids
		]
	) {
		... on Fulfillment {
			id
			moreFields
		}
	}
}"""
    ) {
        bulkOperation {
            id
            createdAt
            completedAt
            errorCode
            objectCount
            partialDataUrl
            type
            status
            url
        }
        userErrors {
            field
            message
        }
    }
}

This bulk operation won't even run. I could run this outside of a bulk operation if there was only 250 ids, but I would like to be able to run an arbitrary amount of ids at once.

 

 

Is there a version of either of these that works? Or other way that I'm missing entirely?

 

Thanks!

Replies 7 (7)

Eric-HAN
Shopify Partner
250 29 26

Hi, there

I see a typeo in you input query.
EricHAN_0-1718761844799.png

 

 
- Helpful? Please hit Like and mark it as a solution
Want to modify or custom changes on store? Let me help.
- Feel free to Email Me    Buy Me A Coffee
Eric-HAN
Shopify Partner
250 29 26

could you share your error message ?

- Helpful? Please hit Like and mark it as a solution
Want to modify or custom changes on store? Let me help.
- Feel free to Email Me    Buy Me A Coffee
it-jkboots
Shopify Partner
8 0 1

Option one doesn't give an error message. It just ignores the query string and runs the query as though there was no query string. Option two gives this error message:

"userErrors": [
	{
		"field": [
			"query"
		],
		"message": "Bulk queries must contain at least one connection."
	}
]

Also, that typeo made it in when I was making the example query string for the query. It wasn't the exact query string I used originally.

ShopifyDevSup
Shopify Staff
1453 238 525

Hey @it-jkboots

 

There are a few issues I'm noticing here, 

 

First off, the id fields are invalid fields for this query, so that is why they are being ignored. Consulting our documentation for this query, the id's field is intended to be a range of fulfillment order id's. I'm seeing you've provided fulfillment id's. 

This is an example of the proper syntax for the id field range: 

 

fulfillmentOrders(
       first: 10
       query: "id:>10584555520022 id:<=10659283042326"
       includeClosed: true
   )

Testing further, adding that to a bulk query, it does run without any issues: 

 

mutation BulkOperationRunQuery {
   bulkOperationRunQuery(
       query: """
       {
   fulfillmentOrders(
       first: 10
       query: "id:>10584555520022 id:<=10659283042326"
       includeClosed: true
   ) {
       edges {
           node {
               id
               fulfillments(first: 10) {
                   edges {
                       node {
                           id
                       }
                   }
               }
           }
       }
   }
}
"""
   ) {
       bulkOperation {
           completedAt
           createdAt
           errorCode
           fileSize
           id
           objectCount
           partialDataUrl
           query
           rootObjectCount
           status
           type
           url
       }
       userErrors {
           field
           message
       }
   }
}

 

Hope that helps, 

 

- Kyle G. 

Developer Support @ Shopify
- Was this reply helpful? Click Like to let us know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

Eric-HAN
Shopify Partner
250 29 26

Very helpful.Thx

 

- Helpful? Please hit Like and mark it as a solution
Want to modify or custom changes on store? Let me help.
- Feel free to Email Me    Buy Me A Coffee
it-jkboots
Shopify Partner
8 0 1

I know both examples I gave are incorrect, but they are the only ways I could think of to accomplish what I am needing. I am wondering if there is anything like the two examples I gave to accomplish what I am needing or if I am missing some solution all together. The reworked example you gave is filtering the fulfillmentOrders query based on fulfillment order ids, but I need to filter based on fulfillment ids. I have a list of fulfillment ids that I need to get the corresponding fulfillments of. I would also like to do it in a bulk operation so I can just wait for the bulk operation completed webhook and not have the app running and paging through results while the results are being found.

Eric-HAN
Shopify Partner
250 29 26

Hi, there

Try this in your bulk replace that 1st query.

 

{
  fulfillmentOrders(first:10 ,query:"id:6363733852443 OR id:6363734966555  OR id:6363743289627",
    includeClosed: true) {
    edges{
        node{
            id
            orderName
        }
        
    }
  }
}

 

 

 

it works  in my side 

EricHAN_0-1719283752657.png

 

- Helpful? Please hit Like and mark it as a solution
Want to modify or custom changes on store? Let me help.
- Feel free to Email Me    Buy Me A Coffee