Shouldn't the ReturnLineItemType include a connection to the LineItem

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.

If this is incorrect - let me know and I’ll flag it to the team.

Hi Liam, thanks for taking a look. I also did the same with with the assistant, but got and error saying that the property lineItem doesn’t exist.

Hi again - unfortunately this does look like a limitation in the GraphQL API, was this previously possible with the REST API?

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?

{
  return(id: "gid://shopify/Return/18574475331") {
    id
    name
    returnLineItems(first: 50) {
      edges {
        cursor
        node {
          fulfillmentLineItem {
            lineItem {
              sku
            }
          }
        }
      }
    }
  }
}

Could you try the below GraphQL(2025-01) query?

query {
  return(id: "gid://shopify/Return/945000954") {
    status
    name
    order {
      id
    }
    returnLineItems(first: 10) {
      edges {
        node {
          ... on ReturnLineItem {
            fulfillmentLineItem {
              lineItem {
                name
              }
            }
            totalWeight {
              value
            }
          }
          quantity
          returnReason
          returnReasonNote
        }
      }
    }
  }
}
3 Likes

Tested. And discovered the “interfaces” or “type” queries, never used before. Thank you so much, this has been a nightmare…

2 Likes

If this is incorrect - let me know and I’ll flag it to the team.

Yes, could you please flag this with the team? It does not work.

@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

@KyleG-Shopify Could you take a look here too please? @Liam-Shopify isn’t replying. :frowning:

Hi @Horse

Which API version are you using? Can you test on 2025-01 and 2025-04?

Yes, all versions up to and including 2024-07, 2024-10, 2025-01, 2025-04 and 2025-07 ALL are affected.

That field does not work since 2024-07.

ezgif-5b174409ee1113

It’s possible this was deprecated but this was not documented. Digging into this more now.

Yeah something funky is going on because there is also this: ReverseFulfillmentOrderLineItem.fulfillmentLineItem field is nullable as of 2024-10 - Shopify developer changelog

But that is talking about ReverseFulfillmentOrderLineItem.fulfillmentLineItem and we are talking about ReturnLineItem.fulfillmentLineItem.

Both of which are: FulfillmentLineItem - GraphQL Admin

It seems like maybe some wires got crossed…

Hey @Horse!

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.

This would be related to the changelog here: 2024-07 release notes

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

Thanks, I just want to make sure I’m not missing anything. I do see it in our docs which looks to align with how other implementations are documented.

This is mentioned here: https://shopify.dev/docs/api/admin-graphql/latest/objects/ReturnLineItem#interfaces

and here: https://shopify.dev/docs/api/admin-graphql/latest/interfaces/ReturnLineItemType#types-implemented-in

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.

Thanks for pointing that out. I see it more clearly now. I’ve submitted that over to our docs team to help make this more clear. :memo: