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

sentry_errors_resolver.rb « error_tracking « resolvers « graphql « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 187cb15ccc5752735b693456da83f501cbc5f079 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# frozen_string_literal: true

module Resolvers
  module ErrorTracking
    class SentryErrorsResolver < BaseResolver
      type Types::ErrorTracking::SentryErrorType.connection_type, null: true

      argument :search_term, ::GraphQL::Types::String,
              description: 'Search query for the Sentry error details.',
              required: false

      # TODO: convert to Enum
      argument :sort, ::GraphQL::Types::String,
              description: 'Attribute to sort on. Options are frequency, first_seen, last_seen. last_seen is default.',
              required: false

      delegate :project, to: :object

      def resolve(**args)
        args[:cursor] = args.delete(:after)

        result = ::ErrorTracking::ListIssuesService.new(project, current_user, args).execute

        next_cursor = result.dig(:pagination, 'next', 'cursor')
        previous_cursor = result.dig(:pagination, 'previous', 'cursor')
        issues = result[:issues]

        # ReactiveCache is still fetching data
        return if issues.nil?

        Gitlab::Graphql::ExternallyPaginatedArray.new(previous_cursor, next_cursor, *issues)
      end
    end
  end
end