Commit 460d5475 authored by Dylan Griffith's avatar Dylan Griffith

Merge branch 'ajk-globalid-metrics' into 'master'

[GraphQL] Metrics: use Global-ID scalar

See merge request gitlab-org/gitlab!36100
parents f923cc7a 4c510efb
...@@ -9,8 +9,7 @@ module Mutations ...@@ -9,8 +9,7 @@ module Mutations
authorize :delete_metrics_dashboard_annotation authorize :delete_metrics_dashboard_annotation
argument :id, argument :id, ::Types::GlobalIDType[::Metrics::Dashboard::Annotation],
GraphQL::ID_TYPE,
required: true, required: true,
description: 'The global ID of the annotation to delete' description: 'The global ID of the annotation to delete'
......
...@@ -5265,7 +5265,7 @@ input DeleteAnnotationInput { ...@@ -5265,7 +5265,7 @@ input DeleteAnnotationInput {
""" """
The global ID of the annotation to delete The global ID of the annotation to delete
""" """
id: ID! id: MetricsDashboardAnnotationID!
} }
""" """
...@@ -13465,6 +13465,11 @@ type MetricsDashboardAnnotationEdge { ...@@ -13465,6 +13465,11 @@ type MetricsDashboardAnnotationEdge {
node: MetricsDashboardAnnotation node: MetricsDashboardAnnotation
} }
"""
Identifier of Metrics::Dashboard::Annotation
"""
scalar MetricsDashboardAnnotationID
""" """
Represents a milestone Represents a milestone
""" """
......
...@@ -14404,7 +14404,7 @@ ...@@ -14404,7 +14404,7 @@
"name": null, "name": null,
"ofType": { "ofType": {
"kind": "SCALAR", "kind": "SCALAR",
"name": "ID", "name": "MetricsDashboardAnnotationID",
"ofType": null "ofType": null
} }
}, },
...@@ -37039,6 +37039,16 @@ ...@@ -37039,6 +37039,16 @@
"enumValues": null, "enumValues": null,
"possibleTypes": null "possibleTypes": null
}, },
{
"kind": "SCALAR",
"name": "MetricsDashboardAnnotationID",
"description": "Identifier of Metrics::Dashboard::Annotation",
"fields": null,
"inputFields": null,
"interfaces": null,
"enumValues": null,
"possibleTypes": null
},
{ {
"kind": "OBJECT", "kind": "OBJECT",
"name": "Milestone", "name": "Milestone",
...@@ -101,9 +101,7 @@ RSpec.describe Mutations::Metrics::Dashboard::Annotations::Create do ...@@ -101,9 +101,7 @@ RSpec.describe Mutations::Metrics::Dashboard::Annotations::Create do
graphql_mutation(:create_annotation, variables) graphql_mutation(:create_annotation, variables)
end end
it_behaves_like 'a mutation that returns top-level errors' do it_behaves_like 'an invalid argument to the mutation', argument_name: :environment_id
let(:match_errors) { include(/is not a valid Global ID/) }
end
end end
end end
end end
...@@ -190,9 +188,7 @@ RSpec.describe Mutations::Metrics::Dashboard::Annotations::Create do ...@@ -190,9 +188,7 @@ RSpec.describe Mutations::Metrics::Dashboard::Annotations::Create do
graphql_mutation(:create_annotation, variables) graphql_mutation(:create_annotation, variables)
end end
it_behaves_like 'a mutation that returns top-level errors' do it_behaves_like 'an invalid argument to the mutation', argument_name: :cluster_id
let(:match_errors) { include(/is not a valid Global ID/) }
end
end end
end end
...@@ -213,35 +209,26 @@ RSpec.describe Mutations::Metrics::Dashboard::Annotations::Create do ...@@ -213,35 +209,26 @@ RSpec.describe Mutations::Metrics::Dashboard::Annotations::Create do
it_behaves_like 'a mutation that returns top-level errors', errors: [described_class::ANNOTATION_SOURCE_ARGUMENT_ERROR] it_behaves_like 'a mutation that returns top-level errors', errors: [described_class::ANNOTATION_SOURCE_ARGUMENT_ERROR]
end end
context 'when a non-cluster or environment id is provided' do [:environment_id, :cluster_id].each do |arg_name|
let(:gid) { { environment_id: project.to_global_id.to_s } } context "when #{arg_name} is given an ID of the wrong type" do
let(:mutation) do let(:gid) { global_id_of(project) }
variables = { let(:mutation) do
starting_at: starting_at, variables = {
ending_at: ending_at, starting_at: starting_at,
dashboard_path: dashboard_path, ending_at: ending_at,
description: description dashboard_path: dashboard_path,
}.merge!(gid) description: description,
arg_name => gid
graphql_mutation(:create_annotation, variables) }
end
before do
project.add_developer(current_user)
end
describe 'non-environment id' do graphql_mutation(:create_annotation, variables)
it_behaves_like 'a mutation that returns top-level errors' do
let(:match_errors) { include(/does not represent an instance of Environment/) }
end end
end
describe 'non-cluster id' do
let(:gid) { { cluster_id: project.to_global_id.to_s } }
it_behaves_like 'a mutation that returns top-level errors' do before do
let(:match_errors) { include(/does not represent an instance of Clusters::Cluster/) } project.add_developer(current_user)
end end
it_behaves_like 'an invalid argument to the mutation', argument_name: arg_name
end end
end end
end end
...@@ -36,7 +36,7 @@ RSpec.describe Mutations::Metrics::Dashboard::Annotations::Delete do ...@@ -36,7 +36,7 @@ RSpec.describe Mutations::Metrics::Dashboard::Annotations::Delete do
let(:variables) { { id: GitlabSchema.id_from_object(project).to_s } } let(:variables) { { id: GitlabSchema.id_from_object(project).to_s } }
it_behaves_like 'a mutation that returns top-level errors' do it_behaves_like 'a mutation that returns top-level errors' do
let(:match_errors) { eq(["#{variables[:id]} is not a valid ID for #{annotation.class}."]) } let(:match_errors) { contain_exactly(include('invalid value for id')) }
end end
end end
......
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