diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-04-23 15:09:55 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-04-23 15:09:55 +0000 |
commit | 9a9415ab127d5e660c09113238a6fb0a895218e9 (patch) | |
tree | 0999f1914bd60e30488fc56bc1ebaeaced925950 /app/graphql/resolvers | |
parent | c6acc1681a6d245e00cc7edebfa2cb7a731e8c96 (diff) | |
download | gitlab-ce-9a9415ab127d5e660c09113238a6fb0a895218e9.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/graphql/resolvers')
-rw-r--r-- | app/graphql/resolvers/issues_resolver.rb | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/app/graphql/resolvers/issues_resolver.rb b/app/graphql/resolvers/issues_resolver.rb index 04da54a6bb6..4d33a874a81 100644 --- a/app/graphql/resolvers/issues_resolver.rb +++ b/app/graphql/resolvers/issues_resolver.rb @@ -52,6 +52,8 @@ module Resolvers type Types::IssueType, null: true + NON_STABLE_CURSOR_SORTS = %i[priority_asc priority_desc].freeze + def resolve(**args) # The project could have been loaded in batch by `BatchLoader`. # At this point we need the `id` of the project to query for issues, so @@ -70,7 +72,15 @@ module Resolvers args[:iids] ||= [args[:iid]].compact args[:attempt_project_search_optimizations] = args[:search].present? - IssuesFinder.new(context[:current_user], args).execute + issues = IssuesFinder.new(context[:current_user], args).execute + + if non_stable_cursor_sort?(args[:sort]) + # Certain complex sorts are not supported by the stable cursor pagination yet. + # In these cases, we use offset pagination, so we return the correct connection. + Gitlab::Graphql::Pagination::OffsetActiveRecordRelationConnection.new(issues) + else + issues + end end def self.resolver_complexity(args, child_complexity:) @@ -79,5 +89,9 @@ module Resolvers complexity end + + def non_stable_cursor_sort?(sort) + NON_STABLE_CURSOR_SORTS.include?(sort) + end end end |