diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-01-31 21:08:52 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-01-31 21:08:52 +0000 |
commit | d5d3c03598df712550acf0c6463a61c6e7dcc19e (patch) | |
tree | d0fdf0f9cd6df46aea6ed16b6556f44055efb642 /app/graphql | |
parent | 0434f38ef1dce4fe640fe1e4542235746ceb943c (diff) | |
download | gitlab-ce-d5d3c03598df712550acf0c6463a61c6e7dcc19e.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/graphql')
5 files changed, 138 insertions, 0 deletions
diff --git a/app/graphql/resolvers/error_tracking/sentry_error_stack_trace_resolver.rb b/app/graphql/resolvers/error_tracking/sentry_error_stack_trace_resolver.rb new file mode 100644 index 00000000000..f5356660569 --- /dev/null +++ b/app/graphql/resolvers/error_tracking/sentry_error_stack_trace_resolver.rb @@ -0,0 +1,35 @@ +# frozen_string_literal: true + +module Resolvers + module ErrorTracking + class SentryErrorStackTraceResolver < BaseResolver + argument :id, GraphQL::ID_TYPE, + required: true, + description: 'ID of the Sentry issue' + + def resolve(**args) + issue_id = GlobalID.parse(args[:id]).model_id + + # Get data from Sentry + response = ::ErrorTracking::IssueLatestEventService.new( + project, + current_user, + { issue_id: issue_id } + ).execute + + event = response[:latest_event] + event.gitlab_project = project if event + + event + end + + private + + def project + return object.gitlab_project if object.respond_to?(:gitlab_project) + + object + end + end + end +end diff --git a/app/graphql/types/error_tracking/sentry_error_collection_type.rb b/app/graphql/types/error_tracking/sentry_error_collection_type.rb index 2e1b75ac84c..121146133cb 100644 --- a/app/graphql/types/error_tracking/sentry_error_collection_type.rb +++ b/app/graphql/types/error_tracking/sentry_error_collection_type.rb @@ -28,6 +28,10 @@ module Types null: true, description: 'Detailed version of a Sentry error on the project', resolver: Resolvers::ErrorTracking::SentryDetailedErrorResolver + field :error_stack_trace, Types::ErrorTracking::SentryErrorStackTraceType, + null: true, + description: 'Stack Trace of Sentry Error', + resolver: Resolvers::ErrorTracking::SentryErrorStackTraceResolver field :external_url, GraphQL::STRING_TYPE, null: true, diff --git a/app/graphql/types/error_tracking/sentry_error_stack_trace_context_type.rb b/app/graphql/types/error_tracking/sentry_error_stack_trace_context_type.rb new file mode 100644 index 00000000000..e6d02c948d5 --- /dev/null +++ b/app/graphql/types/error_tracking/sentry_error_stack_trace_context_type.rb @@ -0,0 +1,29 @@ +# frozen_string_literal: true + +module Types + module ErrorTracking + # rubocop: disable Graphql/AuthorizeTypes + class SentryErrorStackTraceContextType < ::Types::BaseObject + graphql_name 'SentryErrorStackTraceContext' + description 'An object context for a Sentry error stack trace' + + field :line, + GraphQL::INT_TYPE, + null: false, + description: 'Line number of the context' + field :code, + GraphQL::STRING_TYPE, + null: false, + description: 'Code number of the context' + + def line + object[0] + end + + def code + object[1] + end + end + # rubocop: enable Graphql/AuthorizeTypes + end +end diff --git a/app/graphql/types/error_tracking/sentry_error_stack_trace_entry_type.rb b/app/graphql/types/error_tracking/sentry_error_stack_trace_entry_type.rb new file mode 100644 index 00000000000..0747e41e9fb --- /dev/null +++ b/app/graphql/types/error_tracking/sentry_error_stack_trace_entry_type.rb @@ -0,0 +1,48 @@ +# frozen_string_literal: true + +module Types + module ErrorTracking + # rubocop: disable Graphql/AuthorizeTypes + class SentryErrorStackTraceEntryType < ::Types::BaseObject + graphql_name 'SentryErrorStackTraceEntry' + description 'An object containing a stack trace entry for a Sentry error.' + + field :function, GraphQL::STRING_TYPE, + null: true, + description: 'Function in which the Sentry error occurred' + field :col, GraphQL::STRING_TYPE, + null: true, + description: 'Function in which the Sentry error occurred' + field :line, GraphQL::STRING_TYPE, + null: true, + description: 'Function in which the Sentry error occurred' + field :file_name, GraphQL::STRING_TYPE, + null: true, + description: 'File in which the Sentry error occurred' + field :trace_context, [Types::ErrorTracking::SentryErrorStackTraceContextType], + null: true, + description: 'Context of the Sentry error' + + def function + object['function'] + end + + def col + object['colNo'] + end + + def line + object['lineNo'] + end + + def file_name + object['filename'] + end + + def trace_context + object['context'] + end + end + # rubocop: enable Graphql/AuthorizeTypes + end +end diff --git a/app/graphql/types/error_tracking/sentry_error_stack_trace_type.rb b/app/graphql/types/error_tracking/sentry_error_stack_trace_type.rb new file mode 100644 index 00000000000..0e6105d1ff2 --- /dev/null +++ b/app/graphql/types/error_tracking/sentry_error_stack_trace_type.rb @@ -0,0 +1,22 @@ +# frozen_string_literal: true + +module Types + module ErrorTracking + class SentryErrorStackTraceType < ::Types::BaseObject + graphql_name 'SentryErrorStackTrace' + description 'An object containing a stack trace entry for a Sentry error.' + + authorize :read_sentry_issue + + field :issue_id, GraphQL::STRING_TYPE, + null: false, + description: 'ID of the Sentry error' + field :date_received, GraphQL::STRING_TYPE, + null: false, + description: 'Time the stack trace was received by Sentry' + field :stack_trace_entries, [Types::ErrorTracking::SentryErrorStackTraceEntryType], + null: false, + description: 'Stack trace entries for the Sentry error' + end + end +end |