How do I query Order.Returns.ReturnLineItems when it is ReturnLineItemType instead of ReturnLineItem

Topic summary

Issue: When querying Shopify’s GraphQL API, the Order.Returns.ReturnLineItems connection points to ReturnLineItemType (an interface) rather than ReturnLineItem (a concrete type). This prevents direct access to FulfillmentLineItem.LineItem.Sku, which is needed to match returned items with original order line items by SKU.

Goal: Compare Order.LineItem SKU with Return LineItem SKU to determine if items were returned, without writing separate queries.

Solution Found: Use GraphQL inline fragments with the ... on ReturnLineItem syntax to access the concrete type’s fields:

returnLineItems(first: 25) {
  nodes {
    ... on ReturnLineItem {
      fulfillmentLineItem {
        lineItem {
          name
          sku
        }
      }
      quantity
    }
  }
}

This approach allows querying the nested FulfillmentLineItem.LineItem.Sku field by specifying the concrete ReturnLineItem type within the interface connection. Another user confirmed experiencing the same issue with the fulfillmentLineItem field not existing on ReturnLineItemType.

Summarized with AI on November 4. AI used: claude-sonnet-4-5-20250929.

I ended up finding the solution:

ReturnLineItems struct {
				Nodes []struct {
					ReturnLineItem struct {
						RefundableQuantity  int64
						RefundedQuantity    int64
						ReturnReason        string
						ReturnReasonNote    string
						CustomerNote        string
						Quantity            int64
						FulfillmentLineItem struct {
							LineItem struct {
								Name string
								SKU  string
							}
						}
					} `graphql:"... on ReturnLineItem"`
				}
			} `graphql:"returnLineItems(first: 25)"`