Doing some work with Returns at the moment and ran into some issues with the GraphQL Admin API when querying an order for existing returns. It seems that currently there is no way to get any LineItem specific information from the return line item like the name, image etc.
Not sure if I am missing something here that would provide a way to get this information, but at least from what I can see this appears to be a gap in the GraphQL Admin API.
What’s even stranger is that an ExchangeLineItem does include a connection to the LineItem.
Hey - I asked the .dev assistant about this, and it says ReturnLineItemType does indeed have a connection to the LineItem through the fulfillmentLineItem field, which allows you to access LineItem -specific details such as the name. Can you test this on your side? It would look something like:
query GetReturnDetails {
return(id: "gid://shopify/Return/945000954") {
status
name
order {
id
}
returnLineItems(first: 10) {
edges {
node {
fulfillmentLineItem {
lineItem {
name
image {
originalSrc
}
}
}
quantity
returnReason
returnReasonNote
}
}
}
}
}
Apparently this query retrieves the status and name of a return, along with the first 10 returnLineItems. For each returnLineItem, it fetches the associated LineItem’s name and image through the fulfillmentLineItem field.
If you are encountering issues accessing this information, ensure that your app has the required read_returns access scope and that the fulfillmentLineItem field is populated for the ReturnLineItemType.
Hi, fulfillmentLineItem works correctly in API 2024-01 and 2024-04. However it doesn’t work in 2024-07 and newer, and it seems there is no way to get the lineItem being returned. The error: ‘Field ‘fulfillmentLineItem’ doesn’t exist on type ‘ReturnLineItemType’’. Is there any alternative?
@Liam-Shopify Just to be absolutely clear: That field does not work since 2024-07.
“The error: ‘Field ‘fulfillmentLineItem’ doesn’t exist on type ‘ReturnLineItemType’’.” even though it is documented in Shopify’s GraphQL API docs: ReturnLineItem - GraphQL Admin
I was testing here, and the solution provided above by AMaL looks to still be correct. I couldn’t read the text in your gif but when I don’t use the inline fragment I get the same error as you do. The solution is to use fragments.
As of API version 2024-07, the Return.returnLineItems connection is an interface type. This change is designed to accommodate more diverse return item types in the future, and provides more flexibility in handling returns.
To maintain compatibility with existing implementations, adjust your queries to use an inline fragment. The following adjustment ensures that queries continue to function correctly with the new interface type
In that case then the only remaining work from your side is to fix the documentation here: shopify.dev docs/api/admin-graphql/latest/objects/ReturnLineItem
There is NO documentation on the object page for ReturnLineItem that the attribute fulfillmentLineItem is not part of the ReturnLineItem object. It is not mentioned anything that that one attribute fulfillmentLineItem is any different from any of the other attributes that belong to a ReturnLineItem.
Yes there is a link to the ReturnLineItemType interface at the bottom. However, I hardly think that that is sufficient documentation.
And actually, fulfillmentLineItem is missing from the interface definition of ReturnLineItemType!!! So I think the attribute fulfillmentLineItem needs to be removed from the ReturnLineItem and added to the ReturnLineItemType page.