2019-12-26 22:10:19 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Gitlab
|
|
|
|
module Graphql
|
2020-04-22 19:07:51 +05:30
|
|
|
module Pagination
|
2019-12-26 22:10:19 +05:30
|
|
|
# FilterableArrayConnection is useful especially for lazy-loaded values.
|
|
|
|
# It allows us to call a callback only on the slice of array being
|
|
|
|
# rendered in the "after loaded" phase. For example we can check
|
|
|
|
# permissions only on a small subset of items.
|
2020-04-22 19:07:51 +05:30
|
|
|
class FilterableArrayConnection < GraphQL::Pagination::ArrayConnection
|
|
|
|
def nodes
|
|
|
|
@nodes ||= items.filter_callback.call(super)
|
2019-12-26 22:10:19 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|