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.

Re: Fulfillment Address on Bulk Orders

Solved

Fulfillment Address on Bulk Orders

jpola12
Tourist
4 0 2

I am attempting to extract order data on a monthly basis down to the line-item level. One piece of information I need for each line item is where it was fulfilled or is assigned to be fulfilled.

 

Due to the potentially large amount of data, the bulk operation to query the orders is ideal. However, those are limited to a maximum nesting of 2 levels. As far as I can determine, getting to the FulfillmentOrderLineItem level will require over 2 levels, eliminating my ability to use bulk operations in conjunction with orders of a date range.

 

My next attempt was to use a bulk operation in the following format:

{
                fulfillmentOrders (includeClosed:true){
                    edges{
                    node{
                        id
                        orderName
                        createdAt
                        assignedLocation{
                        address1
                        city
                        province
                        zip
                        countryCode
                        }
                        fulfillments{
                        edges{
                            node{
                            id
                            fulfillmentLineItems{
                                edges{
                                node{
                                    id
                                    lineItem{
                                    id
                                    }
                                }
                                }
                            }
                            }
                        }
                        }
                    }
                    }
                }
}
This attempt also seemed heavy as I cannot locate a filter by date, requiring me to load and manage ALL fulfillmentOrders for a shop when I only need a specific range.
 
Finally, paginating through graph queries or REST API calls is laborious and slow as the number of orders in a month increases and there do not appear to be any batching options.
 
Can someone please advise if I am missing something or what route I should take? Thank you!
Accepted Solution (1)

Liam
Community Manager
3108 342 884

This is an accepted solution.

Hi Jpola12,

 

Your approach to using bulk operations feature in the GraphQL Admin API is indeed a good one for large datasets. Unfortunately, you're correct in that the bulk operation have a two-level limit on nesting. This limit is set to ensure the performance and stability of the Shopify platform.

 

For your specific need, you may need to perform multiple operations. One way to do this is to first fetch all orders using the bulk operations feature within your desired date range. From this operation, you can extract all order IDs.

 

In the second operation, you can use these order IDs to fetch the fulfillmentOrders for each order. While this does mean that you're making more queries, you are able to get detailed information about each order's fulfillment.

 

Unfortunately, the GraphQL API does not support filtering by date for the fulfillmentOrders field. However, you can filter fulfillment orders by date in REST API using the created_at_min and created_at_max parameters.

 

As for pagination, GraphQL API provides a more efficient way to paginate results compared to REST. In GraphQL, you can use cursor-based pagination which is a more performant way to traverse larger sets of data.

 

Hope this helps!

Liam | Developer Advocate @ Shopify 
 - Was my reply helpful? Click Like to let me 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

View solution in original post

Replies 2 (2)

Liam
Community Manager
3108 342 884

This is an accepted solution.

Hi Jpola12,

 

Your approach to using bulk operations feature in the GraphQL Admin API is indeed a good one for large datasets. Unfortunately, you're correct in that the bulk operation have a two-level limit on nesting. This limit is set to ensure the performance and stability of the Shopify platform.

 

For your specific need, you may need to perform multiple operations. One way to do this is to first fetch all orders using the bulk operations feature within your desired date range. From this operation, you can extract all order IDs.

 

In the second operation, you can use these order IDs to fetch the fulfillmentOrders for each order. While this does mean that you're making more queries, you are able to get detailed information about each order's fulfillment.

 

Unfortunately, the GraphQL API does not support filtering by date for the fulfillmentOrders field. However, you can filter fulfillment orders by date in REST API using the created_at_min and created_at_max parameters.

 

As for pagination, GraphQL API provides a more efficient way to paginate results compared to REST. In GraphQL, you can use cursor-based pagination which is a more performant way to traverse larger sets of data.

 

Hope this helps!

Liam | Developer Advocate @ Shopify 
 - Was my reply helpful? Click Like to let me 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

jpola12
Tourist
4 0 2

Hi @Liam,

 

Thanks for your reply. I was hoping I was missing a faster approach, but I appreciate you confirming my findings.