How to Paginate Nested Results Like LineItems Inside Orders GraphQL

It’s clear how to paginate through top level results using GraphQL. For example, if I get a list of orders like this using Shopify’s GraphiQL explorer:

{
  orders(first: 10) {
    pageInfo {
      hasNextPage
    }
    edges {
      cursor
      node {
        id
        lineItems(first:5) {
          pageInfo {
            hasNextPage
          }
          edges {
            cursor
            node {
              id
            }
          }
        }
      }
    }
}

I can paginate to the next page of orders like this:

{
  orders(first: 10, after: 

But, it is unclear how to get the line items that are nested inside the result because there's not a "lineItem" resource I can see in the GraphQL API documentation. How do I fetch more line items inside an order given a cursor? More generally, how to fetch more results from a nested resource?
1 Like

Did you get a solution?

Nope, still using REST API’s has_next?. Without pagination support in GraphQL, I have no choice but to use REST API. I wish Shopify would give a GraphQL version.

Nope, still using REST API’s has_next?. Without pagination support in GraphQL, I have no choice but to use REST API. I wish Shopify would give a GraphQL version.