Class: Resolvers::PaginatedTreeResolver
- Inherits:
-
BaseResolver
- Object
- GraphQL::Schema::Resolver
- BaseResolver
- Resolvers::PaginatedTreeResolver
- Defined in:
- app/graphql/resolvers/paginated_tree_resolver.rb
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from BaseResolver
as_single, authorization, authorized?, before_connection_authorization, before_connection_authorization_block, calculate_ext_conn_complexity, calls_gitaly!, complexity, complexity_multiplier, #current_user, last, #object, #offset_pagination, requires_argument!, resolver_complexity, #select_result, single, #single?, single_definition_blocks, singular_type, when_single
Methods included from Gitlab::Utils::Override
#extended, extensions, #included, #method_added, #override, #prepended, #queue_verification, verify!
Class Method Details
.field_options ⇒ Object
54 55 56 |
# File 'app/graphql/resolvers/paginated_tree_resolver.rb', line 54 def self. super.merge(connection: false) # we manage the pagination manually, so opt out of the connection field extension end |
Instance Method Details
#resolve(**args) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'app/graphql/resolvers/paginated_tree_resolver.rb', line 27 def resolve(**args) return if repository.empty? cursor = args.delete(:after) pagination_params = { limit: @field.max_page_size || 100, page_token: cursor } tree = repository.tree( args[:ref].presence || :head, args[:path], recursive: args[:recursive], skip_flat_paths: false, pagination_params: pagination_params, ref_type: args[:ref_type] ) next_cursor = tree.cursor&.next_cursor Gitlab::Graphql::ExternallyPaginatedArray.new(cursor, next_cursor, *tree) rescue Gitlab::Git::CommandError => e raise Gitlab::Graphql::Errors::BaseError.new( e, extensions: { code: e.code, gitaly_code: e.status, service: e.service } ) end |