Skip to content

Fix Gitlab::Graphql::OffsetPaginatedRelation#preload

What does this MR do and why?

Gitlab::Graphql::OffsetPaginatedRelation is just a SimpleDelegator wrapping a relation. But some methods, like #preload, return a new object which loses the offset pagination type hint for GraphQL. To fix it, we simply re-wrap the preloaded relation.

This is all wrapped in a request scoped feature flag, because there is a small but steady stream of occurrences on sentry (internal link), which might all suddenly start working if we fix this.

References

Screenshots or screen recordings

Before After
Screenshot_2025-10-20_at_4.58.01_PM Screenshot_2025-10-20_at_4.58.10_PM

How to set up and validate locally

You can reproduce in /-/graphql-explorer with:

query getPipelines($fullPath: ID!, $scope: PipelineScopeEnum, $first: Int, $last: Int, $after: String = "", $before: String = "") {
  project(fullPath: $fullPath) {
    id
    pipelines(
      scope: $scope
      first: $first
      last: $last
      after: $after
      before: $before
    ) {
      nodes {
        id
        hasManualActions
      }
    }
  }
}

and variables

{
  "after": null,
  "before": null,
  "fullPath": "root/test",
  "first": 15,
  "last": null,
  "scope": "BRANCHES"
}
  • With the flag fix_graphql_offset_pagination_preloads disabled: An error "message": "Internal server error: The order on the scope does not support keyset pagination. You might need to define a custom Order object.\n\nSee https://docs.gitlab.com/ee/development/database/keyset_pagination.html#complex-order-configuration\n\nOr the Gitlab::Pagination::Keyset::Order class for examples\n"
  • With the flag fix_graphql_offset_pagination_preloads enabled: It works

MR acceptance checklist

Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Hordur Freyr Yngvason

Merge request reports

Loading