Getting An Internal Error Sometimes When Querying Product Variants By Collection ID

Topic summary

A developer is experiencing inconsistent behavior when querying product variants by collection ID in Shopify’s GraphQL API.

The Issue:

  • Query works intermittently—succeeds about 50% of the time and throws an internal error the other 50%
  • Using the full GID (Global ID) format always returns no results
  • Using just the numeric ID (e.g., ‘483199713601’) produces the inconsistent error behavior

Query Details:

  • Fetching product variants filtered by collection and inventory quantity
  • Query syntax: collection:'483199713601' AND inventory_quantity:>0

Current Status:

  • The developer has submitted a support ticket
  • Uncertainty exists about whether full GIDs should be used in GraphQL query syntax, with limited documentation available
  • Screenshots were provided showing the error responses
Summarized with AI on November 10. AI used: claude-sonnet-4-5-20250929.

I’m not sure whether you’re supposed to use the full GID in graphql query syntax in general. I would assume that you should but there aren’t really any docs on it.

Query:

query variantsByCollection($query: String!) {
  productVariants(first: 3, query: $query) {
    nodes {
      title
      sku
      inventoryQuantity
    }
  }
}

Variables:

{
  "query": "collection:'483199713601' AND inventory_quantity:>0"
}

When I use just the ID number itself, this query works half of the time and half of the time it throws an internal error (I submitted a support ticket).

When I use the full GID, it always returns back no results.