Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-09-19 15:13:05 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2022-09-19 15:13:05 +0300
commit7de8ed230af7b166e7cc65b3b9351694fadb7d48 (patch)
tree3ca149b952bc4c2c2c6828f1814e323574b3f886 /lib/gitlab/graphql
parentbffc536bf828828a4c05c4e3cbffef83c781448a (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib/gitlab/graphql')
-rw-r--r--lib/gitlab/graphql/pagination/keyset/connection.rb26
1 files changed, 18 insertions, 8 deletions
diff --git a/lib/gitlab/graphql/pagination/keyset/connection.rb b/lib/gitlab/graphql/pagination/keyset/connection.rb
index b5f2c5ee6e8..987a5e7b74b 100644
--- a/lib/gitlab/graphql/pagination/keyset/connection.rb
+++ b/lib/gitlab/graphql/pagination/keyset/connection.rb
@@ -59,11 +59,15 @@ module Gitlab
if before
true
elsif first
- case sliced_nodes
- when Array
- sliced_nodes.size > limit_value
+ if Feature.enabled?(:graphql_keyset_pagination_without_next_page_query)
+ limited_nodes.size > limit_value
else
- sliced_nodes.limit(1).offset(limit_value).exists? # rubocop: disable CodeReuse/ActiveRecord
+ case sliced_nodes
+ when Array
+ sliced_nodes.size > limit_value
+ else
+ sliced_nodes.limit(1).offset(limit_value).exists? # rubocop: disable CodeReuse/ActiveRecord
+ end
end
else
false
@@ -89,7 +93,7 @@ module Gitlab
# So we're ok loading them into memory here as that's bound to happen
# anyway. Having them ready means we can modify the result while
# rendering the fields.
- @nodes ||= limited_nodes.to_a
+ @nodes ||= limited_nodes.to_a.take(limit_value) # rubocop: disable CodeReuse/ActiveRecord
end
def items
@@ -122,9 +126,15 @@ module Gitlab
@has_previous_page = paginated_nodes.count > limit_value
@has_previous_page ? paginated_nodes.last(limit_value) : paginated_nodes
elsif loaded?(sliced_nodes)
- sliced_nodes.take(limit_value) # rubocop: disable CodeReuse/ActiveRecord
+ if Feature.enabled?(:graphql_keyset_pagination_without_next_page_query)
+ sliced_nodes.take(limit_value + 1) # rubocop: disable CodeReuse/ActiveRecord
+ else
+ sliced_nodes.take(limit_value) # rubocop: disable CodeReuse/ActiveRecord
+ end
+ elsif Feature.enabled?(:graphql_keyset_pagination_without_next_page_query)
+ sliced_nodes.limit(limit_value + 1).to_a
else
- sliced_nodes.limit(limit_value) # rubocop: disable CodeReuse/ActiveRecord
+ sliced_nodes.limit(limit_value)
end
end
end
@@ -141,7 +151,7 @@ module Gitlab
def limit_value
# note: only first _or_ last can be specified, not both
- @limit_value ||= [first, last, max_page_size].compact.min
+ @limit_value ||= [first, last, max_page_size, GitlabSchema.default_max_page_size].compact.min
end
def loaded?(items)