Commit bdd0e0db authored by Markus Koller's avatar Markus Koller

Merge branch 'ajk-globalid-error-tracking' into 'master'

[GraphQL] Error tracking: use Global-ID scalar

See merge request gitlab-org/gitlab!36098
parents 8c0fd2c4 7211e6ab
......@@ -5,19 +5,20 @@ module Resolvers
class SentryDetailedErrorResolver < BaseResolver
type Types::ErrorTracking::SentryDetailedErrorType, null: true
argument :id, GraphQL::ID_TYPE,
argument :id, ::Types::GlobalIDType[::Gitlab::ErrorTracking::DetailedError],
required: true,
description: 'ID of the Sentry issue'
def resolve(**args)
current_user = context[:current_user]
issue_id = GlobalID.parse(args[:id])&.model_id
def resolve(id:)
# TODO: remove this line when the compatibility layer is removed
# See: https://gitlab.com/gitlab-org/gitlab/-/issues/257883
id = ::Types::GlobalIDType[::Gitlab::ErrorTracking::DetailedError].coerce_isolated_input(id)
# Get data from Sentry
response = ::ErrorTracking::IssueDetailsService.new(
project,
current_user,
{ issue_id: issue_id }
{ issue_id: id.model_id }
).execute
issue = response[:issue]
issue.gitlab_project = project if issue
......
......@@ -3,18 +3,20 @@
module Resolvers
module ErrorTracking
class SentryErrorStackTraceResolver < BaseResolver
argument :id, GraphQL::ID_TYPE,
argument :id, ::Types::GlobalIDType[::Gitlab::ErrorTracking::DetailedError],
required: true,
description: 'ID of the Sentry issue'
def resolve(**args)
issue_id = GlobalID.parse(args[:id])&.model_id
def resolve(id:)
# TODO: remove this line when the compatibility layer is removed
# See: https://gitlab.com/gitlab-org/gitlab/-/issues/257883
id = ::Types::GlobalIDType[::Gitlab::ErrorTracking::DetailedError].coerce_isolated_input(id)
# Get data from Sentry
response = ::ErrorTracking::IssueLatestEventService.new(
project,
current_user,
{ issue_id: issue_id }
{ issue_id: id.model_id }
).execute
event = response[:latest_event]
......
---
title: Use global IDs for GraphQL arguments accepting sentry IDs
merge_request: 36098
author:
type: changed
......@@ -8267,6 +8267,11 @@ type GeoNode {
verificationMaxCapacity: Int
}
"""
Identifier of Gitlab::ErrorTracking::DetailedError
"""
scalar GitlabErrorTrackingDetailedErrorID
type GrafanaIntegration {
"""
Timestamp of the issue's creation
......@@ -16081,7 +16086,7 @@ type Project {
"""
ID of the Sentry issue
"""
id: ID!
id: GitlabErrorTrackingDetailedErrorID!
): SentryDetailedError
"""
......@@ -19480,7 +19485,7 @@ type SentryErrorCollection {
"""
ID of the Sentry issue
"""
id: ID!
id: GitlabErrorTrackingDetailedErrorID!
): SentryDetailedError
"""
......@@ -19490,7 +19495,7 @@ type SentryErrorCollection {
"""
ID of the Sentry issue
"""
id: ID!
id: GitlabErrorTrackingDetailedErrorID!
): SentryErrorStackTrace
"""
......
......@@ -22891,6 +22891,16 @@
"enumValues": null,
"possibleTypes": null
},
{
"kind": "SCALAR",
"name": "GitlabErrorTrackingDetailedErrorID",
"description": "Identifier of Gitlab::ErrorTracking::DetailedError",
"fields": null,
"inputFields": null,
"interfaces": null,
"enumValues": null,
"possibleTypes": null
},
{
"kind": "OBJECT",
"name": "GrafanaIntegration",
......@@ -46710,7 +46720,7 @@
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "ID",
"name": "GitlabErrorTrackingDetailedErrorID",
"ofType": null
}
},
......@@ -56376,7 +56386,7 @@
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "ID",
"name": "GitlabErrorTrackingDetailedErrorID",
"ofType": null
}
},
......@@ -56403,7 +56413,7 @@
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "ID",
"name": "GitlabErrorTrackingDetailedErrorID",
"ofType": null
}
},
......@@ -65,7 +65,9 @@ RSpec.describe Resolvers::ErrorTracking::SentryDetailedErrorResolver do
context 'blank id' do
let(:args) { { id: '' } }
it_behaves_like 'it resolves to nil'
it 'responds with an error' do
expect { resolve_error(args) }.to raise_error(::GraphQL::CoercionError)
end
end
end
......
......@@ -191,7 +191,7 @@ RSpec.describe 'sentry errors requests' do
describe 'getting a stack trace' do
let_it_be(:sentry_stack_trace) { build(:error_tracking_error_event) }
let(:sentry_gid) { Gitlab::ErrorTracking::DetailedError.new(id: 1).to_global_id.to_s }
let(:sentry_gid) { global_id_of(Gitlab::ErrorTracking::DetailedError.new(id: 1)) }
let(:stack_trace_fields) do
all_graphql_fields_for('SentryErrorStackTrace'.classify)
......
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