[Feature Request] Add subject_id filter to GraphQL Events API

Hello Shopify Developer Community,

I would like to propose a crucial feature enhancement for the events query in the Admin GraphQL API.

The Problem Currently, the events query allows filtering by fields like action and subject_type, but it does not support direct filtering by subject_id, the GID of a specific object.

Primary Use Case A very common scenario for our application is to determine if a product is non-existent because it was deleted, or if it never existed in the first place. The only way to do this currently is as follows:

  1. Fetch all product deletion events using query: "action:'destroy' AND subject_type:'PRODUCT'".

  2. If there are many results, paginate through all of them.

  3. Loop through all the fetched results within our application code to check if our specific subjectId is present.

This workflow is highly inefficient. To check the status of a single product, it forces us to make a large number of unnecessary API calls and transfer a lot of data, leading to significant performance degradation and a spike in API usage.

Proposed Solution I propose enhancing the query argument for the events field to support filtering by subject_id, allowing for a query like this:

GraphQL

query {
  events(first: 1, query: "action:'destroy' AND subject_type:'PRODUCT' AND subject_id:'gid://shopify/Product/1234567890'") {
    edges {
      node {
        id
        ... on BasicEvent {
          subjectId
        }
      }
    }
  }
}

Benefits

  • Increased API Efficiency: Get the exact result needed in a single, precise query.

  • Improved Developer Experience: Eliminates the need for complex pagination and client-side filtering logic.

  • Reduced Server Load: Decreases the load on both Shopify’s servers and our own application servers.

I am confident that this feature would be a valuable addition for many developers trying to build stable and efficient apps on the Shopify platform.

Thank you for your consideration.

1 Like

Hey @KubrickCode,

Thanks for bringing up this feature request and taking the time to explain your use case. I did some tests just to confirm, and I see that subject_id filtering isn’t currently supported in the events query. When you try to use it, the API returns an “Invalid search field for this query” warning and ignores that filter entirely.

I’ll pass this feature request along to the team for consideration. In the meantime, if you’re specifically trying to check whether a product was deleted, you might find it more efficient to use the created_at filter to narrow down to more recent events (like created_at:>2025-01-01) rather than paginating through the entire event history, which should help reduce the data transfer and API calls while you’re working with the current system.

Hey @KubrickCode, I wanted to share an update here. I’ve passed your feedback on and our team will be reviewing if this is something they will be adding.

I don’t have a timeline at this point, but any changes here will be noted in the developers changelog

@KyleG-Shopify Thank you for sharing my feedback with your team.
It may not be technically feasible, but it’s an important feature to me, so I hope it gets supported quickly.

1 Like