Commit 7e2ff88b authored by charlie ablett's avatar charlie ablett

Merge branch '268042-graphql-use-new-global-id-for-security-dashboard' into 'master'

Update RemoveProjectFromSecurityDashboard mutation to use new Global IDs

See merge request gitlab-org/gitlab!45500
parents 86860616 3a44ee7e
...@@ -1274,7 +1274,6 @@ Graphql/IDType: ...@@ -1274,7 +1274,6 @@ Graphql/IDType:
Exclude: Exclude:
- 'ee/app/graphql/ee/mutations/issues/update.rb' - 'ee/app/graphql/ee/mutations/issues/update.rb'
- 'ee/app/graphql/ee/types/boards/board_issue_input_base_type.rb' - 'ee/app/graphql/ee/types/boards/board_issue_input_base_type.rb'
- 'ee/app/graphql/mutations/instance_security_dashboard/remove_project.rb'
- 'ee/app/graphql/mutations/issues/set_epic.rb' - 'ee/app/graphql/mutations/issues/set_epic.rb'
- 'ee/app/graphql/mutations/iterations/update.rb' - 'ee/app/graphql/mutations/iterations/update.rb'
- 'ee/app/graphql/resolvers/iterations_resolver.rb' - 'ee/app/graphql/resolvers/iterations_resolver.rb'
......
...@@ -16396,7 +16396,7 @@ input RemoveProjectFromSecurityDashboardInput { ...@@ -16396,7 +16396,7 @@ input RemoveProjectFromSecurityDashboardInput {
""" """
ID of the project to remove from the Instance Security Dashboard ID of the project to remove from the Instance Security Dashboard
""" """
id: ID! id: ProjectID!
} }
""" """
......
...@@ -47191,7 +47191,7 @@ ...@@ -47191,7 +47191,7 @@
"name": null, "name": null,
"ofType": { "ofType": {
"kind": "SCALAR", "kind": "SCALAR",
"name": "ID", "name": "ProjectID",
"ofType": null "ofType": null
} }
}, },
...@@ -7,7 +7,7 @@ module Mutations ...@@ -7,7 +7,7 @@ module Mutations
authorize :read_instance_security_dashboard authorize :read_instance_security_dashboard
argument :id, GraphQL::ID_TYPE, argument :id, Types::GlobalIDType[::Project],
required: true, required: true,
description: 'ID of the project to remove from the Instance Security Dashboard' description: 'ID of the project to remove from the Instance Security Dashboard'
...@@ -31,7 +31,9 @@ module Mutations ...@@ -31,7 +31,9 @@ module Mutations
def extract_project_id(gid) def extract_project_id(gid)
return unless gid.present? return unless gid.present?
GitlabSchema.parse_gid(gid, expected_type: ::Project).model_id # TODO: remove explicit coercion once compatibility layer has been removed
# See: https://gitlab.com/gitlab-org/gitlab/-/issues/257883
Types::GlobalIDType[::Project].coerce_isolated_input(gid).model_id
end end
def remove_project(project_id) def remove_project(project_id)
......
---
title: Update RemoveProjectFromSecurityDashboard mutation to use new Global IDs
merge_request: 45500
author:
type: changed
...@@ -45,6 +45,17 @@ RSpec.describe Mutations::InstanceSecurityDashboard::RemoveProject do ...@@ -45,6 +45,17 @@ RSpec.describe Mutations::InstanceSecurityDashboard::RemoveProject do
it { is_expected.to eq(errors: ['The project does not belong to your dashboard or you don\'t have permission to perform this action']) } it { is_expected.to eq(errors: ['The project does not belong to your dashboard or you don\'t have permission to perform this action']) }
end end
context 'when provided project_id is not a Project' do
let(:project_id) { 'gid://gitlab/Vulnerability/1' }
it 'raises an error' do
expect { subject }.to raise_error(
GraphQL::CoercionError,
"\"#{project_id}\" does not represent an instance of Project"
)
end
end
context 'when project is configured in security dashboard' do context 'when project is configured in security dashboard' do
let(:project_id) { GitlabSchema.id_from_object(already_added_project) } let(:project_id) { GitlabSchema.id_from_object(already_added_project) }
......
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