Unable to get the SKU for a Return Line Item

Solved

Unable to get the SKU for a Return Line Item

cogentnk
Shopify Partner
2 1 1

Hey there,

I am working on an integration to pull returns out of Shopify's GraphQL API and I am wanting to pull the SKU of a Return Line Item from the ReturnLineItemTypeConnection.

There is currently not a SKU field or a Line Item connection that I can then gather the SKU for the ReturnLineItem through that way. RefundLineItem do have the LineItem connection but it seems to ReturnLineItem is missing that connection and there is seemingly not a way to gather it.

https://shopify.dev/docs/api/admin-graphql/latest/queries/orders If you look at Returns > returnLineItems you wil l see the available fields:

returnLineItemScreenshot.png

There is an ID field available however, that returns a value such as gid://shopify/ReturnLineItem/0123456789 which has no way to link back to the LineItem to get the SKU.

 

Any help would be appreciated to help me get the ReturnLineItem SKU and I am also using API version: 2025-01.

 

Many thanks,

 

Accepted Solution (1)

cogentnk
Shopify Partner
2 1 1

This is an accepted solution.

If anyone is interested this is how I solved this: 

query { orders(first: 25, query: "return_status:IN_PROGRESS") { pageInfo { startCursor hasPreviousPage hasNextPage endCursor } nodes { id displayFinancialStatus displayFulfillmentStatus createdAt updatedAt email name returns(first: 20) { nodes { id status name returnLineItems(first: 20) { edges { node { ... on ReturnLineItem { fulfillmentLineItem { lineItem { id sku } } } quantity returnReason returnReasonNote } } } } } } } }

I used the 'on' operator to link it to the fulfilmentLineItem which then you can use to get the related sku & id from the line item. Hope that helps people in the future. Many thanks

View solution in original post

Reply 1 (1)

cogentnk
Shopify Partner
2 1 1

This is an accepted solution.

If anyone is interested this is how I solved this: 

query { orders(first: 25, query: "return_status:IN_PROGRESS") { pageInfo { startCursor hasPreviousPage hasNextPage endCursor } nodes { id displayFinancialStatus displayFulfillmentStatus createdAt updatedAt email name returns(first: 20) { nodes { id status name returnLineItems(first: 20) { edges { node { ... on ReturnLineItem { fulfillmentLineItem { lineItem { id sku } } } quantity returnReason returnReasonNote } } } } } } } }

I used the 'on' operator to link it to the fulfilmentLineItem which then you can use to get the related sku & id from the line item. Hope that helps people in the future. Many thanks