Solved

Support requested for bulk GraphQL queries containing a connection field within a list

Lull
Excursionist
37 1 10

Hi,

 

I want to fetch all orders including their fulfillment and refund line items.
When I execute the bulk GraphQL query below, I get the following error message:

 

"Queries that contain a connection field within a list field are not currently supported."

 

This is caused by orders.fulfillments.fulfillmentLineItems and order.refunds.refundLineItems.
I believe I can get the same information with the REST API faster when such queries are not supported by the GraphQL bulk queries.

 

The bulk query is:

 
mutation {
  bulkOperationRunQuery(
  query: """
    {
      orders{
        edges{
          cursor
          node{
            id
            name
            displayFinancialStatus 
            displayFulfillmentStatus 
            totalPrice
            lineItems{
              edges{
                node{
                  id
                    variant{
                      id
                    }
                  quantity
                }
              }
            }
            fulfillments{
              fulfillmentLineItems{
              edges{
                node{
                  id
                  lineItem{
                    id
                      variant{
                        id
                      }
                  }
                  quantity
                }
              }
              }
            }
            refunds{
              refundLineItems{
              edges{
                node{
                  lineItem{
                    id
                      variant{
                        id
                      }
                  }
                  quantity
                }
              }
              }
            }
            updatedAt
            cancelledAt
            closedAt
          }
        }
      }
    
    }
    """
  ) {
    bulkOperation {
      id
      status
    }
    userErrors {
      field
      message
    }
  }
}

 

If I convert this to a regular query, the cost is 241 for getting 25 orders - meaning it will take 5s to refill the bucket with this cost? With the REST API I would be able to get 500 orders per second.

The regular query is:

query
    {
      orders (first:25 after: "eyJsYXN0X2lkIjoxMjg4MDg2OTc4NjA4LCJsYXN0X3ZhbHVlIjoiMjAxOS0wOC0wOSAwOTo1MTo0NSJ9"){
        edges{
          cursor
          node{
            id
            name
            displayFinancialStatus 
            displayFulfillmentStatus 
            totalPrice
            lineItems(first:5){
              edges{
                node{
                  id
                    variant{
                      id
                    }
                  quantity
                }
              }
            }
            fulfillments{
              fulfillmentLineItems{
              edges{
                node{
                  id
                  lineItem{
                    id
                      variant{
                        id
                      }
                  }
                  quantity
                }
              }
              }
            }
            refunds{
              refundLineItems (first:5){
              edges{
                node{
                  lineItem{
                    id
                      variant{
                        id
                      }
                  }
                  quantity
                }
              }
              }
            }
            updatedAt
            cancelledAt
            closedAt
          }
        }
        pageInfo{
          hasNextPage
        }
      }
    
    }

 

Am I overlooking something?

Thanks,

-Louise

 

Accepted Solution (1)

_JB
Shopify Staff
836 100 223

This is an accepted solution.

Hey @Lull,

 

I checked your query and can confirm the error you're receiving is expected when trying to preform a bulk operation on the orders object using refundLineItems or fulfillments with connections. Although this isn't currently supported, you should be able to get the desired information from connections available directly on the order object. I put together this query which grabs refund and fulfillment data directly from lineItems and transactions

 

mutation {
  bulkOperationRunQuery(
  query: """
{
  orders {
    edges {
      node {
        id
        totalPriceSet {
          shopMoney {
            amount
          }}
        name
        displayFinancialStatus
        displayFulfillmentStatus
        
        lineItems {
          edges {
            node {
              id
              variant {
                id
              }
              quantity
              fulfillmentStatus
              fulfillableQuantity
              refundableQuantity
            }}}
        transactions {
          id
          kind
          amountSet {
            shopMoney {
              amount
    }}}}}}}

"""
) {
    bulkOperation {
      id
      status
    }
    userErrors {
      field
      message
     }}

JB | Solutions Engineer @ Shopify 
 - 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 3 (3)

_JB
Shopify Staff
836 100 223

This is an accepted solution.

Hey @Lull,

 

I checked your query and can confirm the error you're receiving is expected when trying to preform a bulk operation on the orders object using refundLineItems or fulfillments with connections. Although this isn't currently supported, you should be able to get the desired information from connections available directly on the order object. I put together this query which grabs refund and fulfillment data directly from lineItems and transactions

 

mutation {
  bulkOperationRunQuery(
  query: """
{
  orders {
    edges {
      node {
        id
        totalPriceSet {
          shopMoney {
            amount
          }}
        name
        displayFinancialStatus
        displayFulfillmentStatus
        
        lineItems {
          edges {
            node {
              id
              variant {
                id
              }
              quantity
              fulfillmentStatus
              fulfillableQuantity
              refundableQuantity
            }}}
        transactions {
          id
          kind
          amountSet {
            shopMoney {
              amount
    }}}}}}}

"""
) {
    bulkOperation {
      id
      status
    }
    userErrors {
      field
      message
     }}

JB | Solutions Engineer @ Shopify 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

Lull
Excursionist
37 1 10

Hi _JB,

 

Thanks, I think that might do the trick, otherwize I'll get back to you.

 

-Louise

Veesy
Shopify Partner
13 0 4

Hello, how about getting the fulfillment date and time ? Getting when was the line item fulfilled.