Commit 4d04c932 authored by Alex Kalderimis's avatar Alex Kalderimis

Add type annotations for error tracking resolvers

This also moves other metadata to the resolvers, rather than the field
definitions.

Includes updates to the generated GraphQL documentation.
parent 2fb396e3
...@@ -44,7 +44,6 @@ Graphql/ResolverType: ...@@ -44,7 +44,6 @@ Graphql/ResolverType:
- 'app/graphql/resolvers/base_resolver.rb' - 'app/graphql/resolvers/base_resolver.rb'
- 'app/graphql/resolvers/ci/jobs_resolver.rb' - 'app/graphql/resolvers/ci/jobs_resolver.rb'
- 'app/graphql/resolvers/ci/pipeline_stages_resolver.rb' - 'app/graphql/resolvers/ci/pipeline_stages_resolver.rb'
- 'app/graphql/resolvers/error_tracking/sentry_error_stack_trace_resolver.rb'
- 'app/graphql/resolvers/merge_requests_resolver.rb' - 'app/graphql/resolvers/merge_requests_resolver.rb'
- 'app/graphql/resolvers/users/group_count_resolver.rb' - 'app/graphql/resolvers/users/group_count_resolver.rb'
- 'ee/app/graphql/resolvers/geo/merge_request_diff_registries_resolver.rb' - 'ee/app/graphql/resolvers/geo/merge_request_diff_registries_resolver.rb'
......
...@@ -3,6 +3,8 @@ ...@@ -3,6 +3,8 @@
module Resolvers module Resolvers
module ErrorTracking module ErrorTracking
class SentryErrorStackTraceResolver < BaseResolver class SentryErrorStackTraceResolver < BaseResolver
type Types::ErrorTracking::SentryErrorStackTraceType, null: true
argument :id, ::Types::GlobalIDType[::Gitlab::ErrorTracking::DetailedError], argument :id, ::Types::GlobalIDType[::Gitlab::ErrorTracking::DetailedError],
required: true, required: true,
description: 'ID of the Sentry issue' description: 'ID of the Sentry issue'
......
...@@ -4,19 +4,26 @@ module Resolvers ...@@ -4,19 +4,26 @@ module Resolvers
module ErrorTracking module ErrorTracking
class SentryErrorsResolver < BaseResolver class SentryErrorsResolver < BaseResolver
type Types::ErrorTracking::SentryErrorType.connection_type, null: true type Types::ErrorTracking::SentryErrorType.connection_type, null: true
extension Gitlab::Graphql::Extensions::ExternallyPaginatedArrayExtension
argument :search_term, ::GraphQL::STRING_TYPE,
description: 'Search query for the Sentry error details',
required: false
# TODO: convert to Enum
argument :sort, ::GraphQL::STRING_TYPE,
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) def resolve(**args)
args[:cursor] = args.delete(:after) args[:cursor] = args.delete(:after)
project = object.project
result = ::ErrorTracking::ListIssuesService.new( result = ::ErrorTracking::ListIssuesService.new(project, current_user, args).execute
project,
context[:current_user],
args
).execute
next_cursor = result[:pagination]&.dig('next', 'cursor') next_cursor = result.dig(:pagination, 'next', 'cursor')
previous_cursor = result[:pagination]&.dig('previous', 'cursor') previous_cursor = result.dig(:pagination, 'previous', 'cursor')
issues = result[:issues] issues = result[:issues]
# ReactiveCache is still fetching data # ReactiveCache is still fetching data
...@@ -24,6 +31,10 @@ module Resolvers ...@@ -24,6 +31,10 @@ module Resolvers
Gitlab::Graphql::ExternallyPaginatedArray.new(previous_cursor, next_cursor, *issues) Gitlab::Graphql::ExternallyPaginatedArray.new(previous_cursor, next_cursor, *issues)
end end
def self.field_options
super.merge(connection: false) # we manage the pagination manually, so opt out of the connection field extension
end
end end
end end
end end
...@@ -9,27 +9,12 @@ module Types ...@@ -9,27 +9,12 @@ module Types
authorize :read_sentry_issue authorize :read_sentry_issue
field :errors, field :errors,
Types::ErrorTracking::SentryErrorType.connection_type,
connection: false,
null: true,
description: "Collection of Sentry Errors", description: "Collection of Sentry Errors",
extensions: [Gitlab::Graphql::Extensions::ExternallyPaginatedArrayExtension], resolver: Resolvers::ErrorTracking::SentryErrorsResolver
resolver: Resolvers::ErrorTracking::SentryErrorsResolver do field :detailed_error,
argument :search_term,
String,
description: 'Search query for the Sentry error details',
required: false
argument :sort,
String,
description: 'Attribute to sort on. Options are frequency, first_seen, last_seen. last_seen is default',
required: false
end
field :detailed_error, Types::ErrorTracking::SentryDetailedErrorType,
null: true,
description: 'Detailed version of a Sentry error on the project', description: 'Detailed version of a Sentry error on the project',
resolver: Resolvers::ErrorTracking::SentryDetailedErrorResolver resolver: Resolvers::ErrorTracking::SentryDetailedErrorResolver
field :error_stack_trace, Types::ErrorTracking::SentryErrorStackTraceType, field :error_stack_trace,
null: true,
description: 'Stack Trace of Sentry Error', description: 'Stack Trace of Sentry Error',
resolver: Resolvers::ErrorTracking::SentryErrorStackTraceResolver resolver: Resolvers::ErrorTracking::SentryErrorStackTraceResolver
field :external_url, field :external_url,
......
...@@ -57602,8 +57602,8 @@ ...@@ -57602,8 +57602,8 @@
"description": "Collection of Sentry Errors", "description": "Collection of Sentry Errors",
"args": [ "args": [
{ {
"name": "after", "name": "searchTerm",
"description": "Returns the elements in the list that come after the specified cursor.", "description": "Search query for the Sentry error details",
"type": { "type": {
"kind": "SCALAR", "kind": "SCALAR",
"name": "String", "name": "String",
...@@ -57612,8 +57612,8 @@ ...@@ -57612,8 +57612,8 @@
"defaultValue": null "defaultValue": null
}, },
{ {
"name": "before", "name": "sort",
"description": "Returns the elements in the list that come before the specified cursor.", "description": "Attribute to sort on. Options are frequency, first_seen, last_seen. last_seen is default",
"type": { "type": {
"kind": "SCALAR", "kind": "SCALAR",
"name": "String", "name": "String",
...@@ -57622,41 +57622,41 @@ ...@@ -57622,41 +57622,41 @@
"defaultValue": null "defaultValue": null
}, },
{ {
"name": "first", "name": "after",
"description": "Returns the first _n_ elements from the list.", "description": "Returns the elements in the list that come after the specified cursor.",
"type": { "type": {
"kind": "SCALAR", "kind": "SCALAR",
"name": "Int", "name": "String",
"ofType": null "ofType": null
}, },
"defaultValue": null "defaultValue": null
}, },
{ {
"name": "last", "name": "before",
"description": "Returns the last _n_ elements from the list.", "description": "Returns the elements in the list that come before the specified cursor.",
"type": { "type": {
"kind": "SCALAR", "kind": "SCALAR",
"name": "Int", "name": "String",
"ofType": null "ofType": null
}, },
"defaultValue": null "defaultValue": null
}, },
{ {
"name": "searchTerm", "name": "first",
"description": "Search query for the Sentry error details", "description": "Returns the first _n_ elements from the list.",
"type": { "type": {
"kind": "SCALAR", "kind": "SCALAR",
"name": "String", "name": "Int",
"ofType": null "ofType": null
}, },
"defaultValue": null "defaultValue": null
}, },
{ {
"name": "sort", "name": "last",
"description": "Attribute to sort on. Options are frequency, first_seen, last_seen. last_seen is default", "description": "Returns the last _n_ elements from the list.",
"type": { "type": {
"kind": "SCALAR", "kind": "SCALAR",
"name": "String", "name": "Int",
"ofType": null "ofType": null
}, },
"defaultValue": null "defaultValue": null
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment