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 ...@@ -5,19 +5,20 @@ module Resolvers
class SentryDetailedErrorResolver < BaseResolver class SentryDetailedErrorResolver < BaseResolver
type Types::ErrorTracking::SentryDetailedErrorType, null: true type Types::ErrorTracking::SentryDetailedErrorType, null: true
argument :id, GraphQL::ID_TYPE, argument :id, ::Types::GlobalIDType[::Gitlab::ErrorTracking::DetailedError],
required: true, required: true,
description: 'ID of the Sentry issue' description: 'ID of the Sentry issue'
def resolve(**args) def resolve(id:)
current_user = context[:current_user] # TODO: remove this line when the compatibility layer is removed
issue_id = GlobalID.parse(args[:id])&.model_id # See: https://gitlab.com/gitlab-org/gitlab/-/issues/257883
id = ::Types::GlobalIDType[::Gitlab::ErrorTracking::DetailedError].coerce_isolated_input(id)
# Get data from Sentry # Get data from Sentry
response = ::ErrorTracking::IssueDetailsService.new( response = ::ErrorTracking::IssueDetailsService.new(
project, project,
current_user, current_user,
{ issue_id: issue_id } { issue_id: id.model_id }
).execute ).execute
issue = response[:issue] issue = response[:issue]
issue.gitlab_project = project if issue issue.gitlab_project = project if issue
......
...@@ -3,18 +3,20 @@ ...@@ -3,18 +3,20 @@
module Resolvers module Resolvers
module ErrorTracking module ErrorTracking
class SentryErrorStackTraceResolver < BaseResolver class SentryErrorStackTraceResolver < BaseResolver
argument :id, GraphQL::ID_TYPE, argument :id, ::Types::GlobalIDType[::Gitlab::ErrorTracking::DetailedError],
required: true, required: true,
description: 'ID of the Sentry issue' description: 'ID of the Sentry issue'
def resolve(**args) def resolve(id:)
issue_id = GlobalID.parse(args[:id])&.model_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 # Get data from Sentry
response = ::ErrorTracking::IssueLatestEventService.new( response = ::ErrorTracking::IssueLatestEventService.new(
project, project,
current_user, current_user,
{ issue_id: issue_id } { issue_id: id.model_id }
).execute ).execute
event = response[:latest_event] 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 { ...@@ -8267,6 +8267,11 @@ type GeoNode {
verificationMaxCapacity: Int verificationMaxCapacity: Int
} }
"""
Identifier of Gitlab::ErrorTracking::DetailedError
"""
scalar GitlabErrorTrackingDetailedErrorID
type GrafanaIntegration { type GrafanaIntegration {
""" """
Timestamp of the issue's creation Timestamp of the issue's creation
...@@ -16081,7 +16086,7 @@ type Project { ...@@ -16081,7 +16086,7 @@ type Project {
""" """
ID of the Sentry issue ID of the Sentry issue
""" """
id: ID! id: GitlabErrorTrackingDetailedErrorID!
): SentryDetailedError ): SentryDetailedError
""" """
...@@ -19480,7 +19485,7 @@ type SentryErrorCollection { ...@@ -19480,7 +19485,7 @@ type SentryErrorCollection {
""" """
ID of the Sentry issue ID of the Sentry issue
""" """
id: ID! id: GitlabErrorTrackingDetailedErrorID!
): SentryDetailedError ): SentryDetailedError
""" """
...@@ -19490,7 +19495,7 @@ type SentryErrorCollection { ...@@ -19490,7 +19495,7 @@ type SentryErrorCollection {
""" """
ID of the Sentry issue ID of the Sentry issue
""" """
id: ID! id: GitlabErrorTrackingDetailedErrorID!
): SentryErrorStackTrace ): SentryErrorStackTrace
""" """
......
...@@ -22891,6 +22891,16 @@ ...@@ -22891,6 +22891,16 @@
"enumValues": null, "enumValues": null,
"possibleTypes": 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", "kind": "OBJECT",
"name": "GrafanaIntegration", "name": "GrafanaIntegration",
...@@ -46710,7 +46720,7 @@ ...@@ -46710,7 +46720,7 @@
"name": null, "name": null,
"ofType": { "ofType": {
"kind": "SCALAR", "kind": "SCALAR",
"name": "ID", "name": "GitlabErrorTrackingDetailedErrorID",
"ofType": null "ofType": null
} }
}, },
...@@ -56376,7 +56386,7 @@ ...@@ -56376,7 +56386,7 @@
"name": null, "name": null,
"ofType": { "ofType": {
"kind": "SCALAR", "kind": "SCALAR",
"name": "ID", "name": "GitlabErrorTrackingDetailedErrorID",
"ofType": null "ofType": null
} }
}, },
...@@ -56403,7 +56413,7 @@ ...@@ -56403,7 +56413,7 @@
"name": null, "name": null,
"ofType": { "ofType": {
"kind": "SCALAR", "kind": "SCALAR",
"name": "ID", "name": "GitlabErrorTrackingDetailedErrorID",
"ofType": null "ofType": null
} }
}, },
...@@ -65,7 +65,9 @@ RSpec.describe Resolvers::ErrorTracking::SentryDetailedErrorResolver do ...@@ -65,7 +65,9 @@ RSpec.describe Resolvers::ErrorTracking::SentryDetailedErrorResolver do
context 'blank id' do context 'blank id' do
let(:args) { { id: '' } } 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
end end
......
...@@ -191,7 +191,7 @@ RSpec.describe 'sentry errors requests' do ...@@ -191,7 +191,7 @@ RSpec.describe 'sentry errors requests' do
describe 'getting a stack trace' do describe 'getting a stack trace' do
let_it_be(:sentry_stack_trace) { build(:error_tracking_error_event) } 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 let(:stack_trace_fields) do
all_graphql_fields_for('SentryErrorStackTrace'.classify) 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