Commit 06873677 authored by charlie ablett's avatar charlie ablett

Merge branch '268042-graphql_id_type_cop_fix' into 'master'

Fix Graphql/IDType cop for some files

See merge request gitlab-org/gitlab!45342
parents 6b0c3a59 6d8a9df4
...@@ -1251,10 +1251,8 @@ Graphql/IDType: ...@@ -1251,10 +1251,8 @@ 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/boards/lists/update_limit_metrics.rb'
- 'ee/app/graphql/mutations/instance_security_dashboard/remove_project.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/issues/set_iteration.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'
- 'app/graphql/mutations/boards/create.rb' - 'app/graphql/mutations/boards/create.rb'
...@@ -1262,17 +1260,13 @@ Graphql/IDType: ...@@ -1262,17 +1260,13 @@ Graphql/IDType:
- 'app/graphql/mutations/boards/lists/update.rb' - 'app/graphql/mutations/boards/lists/update.rb'
- 'app/graphql/mutations/discussions/toggle_resolve.rb' - 'app/graphql/mutations/discussions/toggle_resolve.rb'
- 'app/graphql/mutations/issues/update.rb' - 'app/graphql/mutations/issues/update.rb'
- 'app/graphql/mutations/merge_requests/set_milestone.rb'
- 'app/graphql/mutations/metrics/dashboard/annotations/delete.rb' - 'app/graphql/mutations/metrics/dashboard/annotations/delete.rb'
- 'app/graphql/mutations/notes/create/note.rb' - 'app/graphql/mutations/notes/create/note.rb'
- 'app/graphql/mutations/notes/update/base.rb' - 'app/graphql/mutations/notes/update/base.rb'
- 'app/graphql/mutations/snippets/destroy.rb' - 'app/graphql/mutations/snippets/destroy.rb'
- 'app/graphql/mutations/snippets/mark_as_spam.rb' - 'app/graphql/mutations/snippets/mark_as_spam.rb'
- 'app/graphql/mutations/snippets/update.rb' - 'app/graphql/mutations/snippets/update.rb'
- 'app/graphql/mutations/todos/mark_done.rb'
- 'app/graphql/mutations/todos/restore.rb'
- 'app/graphql/resolvers/board_lists_resolver.rb' - 'app/graphql/resolvers/board_lists_resolver.rb'
- 'app/graphql/resolvers/board_resolver.rb'
- 'app/graphql/resolvers/boards_resolver.rb' - 'app/graphql/resolvers/boards_resolver.rb'
- 'app/graphql/resolvers/design_management/design_at_version_resolver.rb' - 'app/graphql/resolvers/design_management/design_at_version_resolver.rb'
- 'app/graphql/resolvers/design_management/design_resolver.rb' - 'app/graphql/resolvers/design_management/design_resolver.rb'
......
...@@ -6,7 +6,7 @@ module Mutations ...@@ -6,7 +6,7 @@ module Mutations
graphql_name 'MergeRequestSetMilestone' graphql_name 'MergeRequestSetMilestone'
argument :milestone_id, argument :milestone_id,
GraphQL::ID_TYPE, ::Types::GlobalIDType[::Milestone],
required: false, required: false,
loads: Types::MilestoneType, loads: Types::MilestoneType,
description: <<~DESC description: <<~DESC
......
...@@ -8,7 +8,7 @@ module Mutations ...@@ -8,7 +8,7 @@ module Mutations
authorize :update_todo authorize :update_todo
argument :id, argument :id,
GraphQL::ID_TYPE, ::Types::GlobalIDType[::Todo],
required: true, required: true,
description: 'The global id of the todo to mark as done' description: 'The global id of the todo to mark as done'
......
...@@ -8,7 +8,7 @@ module Mutations ...@@ -8,7 +8,7 @@ module Mutations
authorize :update_todo authorize :update_todo
argument :id, argument :id,
GraphQL::ID_TYPE, ::Types::GlobalIDType[::Todo],
required: true, required: true,
description: 'The global id of the todo to restore' description: 'The global id of the todo to restore'
......
...@@ -6,7 +6,7 @@ module Resolvers ...@@ -6,7 +6,7 @@ module Resolvers
type Types::BoardType, null: true type Types::BoardType, null: true
argument :id, GraphQL::ID_TYPE, argument :id, ::Types::GlobalIDType[::Board],
required: true, required: true,
description: 'The board\'s ID' description: 'The board\'s ID'
......
...@@ -1945,7 +1945,7 @@ input BoardListUpdateLimitMetricsInput { ...@@ -1945,7 +1945,7 @@ input BoardListUpdateLimitMetricsInput {
""" """
The global ID of the list. The global ID of the list.
""" """
listId: ID! listId: ListID!
""" """
The new maximum issue count limit. The new maximum issue count limit.
...@@ -7504,7 +7504,7 @@ type Group { ...@@ -7504,7 +7504,7 @@ type Group {
""" """
The board's ID The board's ID
""" """
id: ID! id: BoardID!
): Board ): Board
""" """
...@@ -9558,7 +9558,7 @@ input IssueSetIterationInput { ...@@ -9558,7 +9558,7 @@ input IssueSetIterationInput {
""" """
The iteration to assign to the issue. The iteration to assign to the issue.
""" """
iterationId: ID iterationId: IterationID
""" """
The project the issue to mutate is in The project the issue to mutate is in
...@@ -11569,7 +11569,7 @@ input MergeRequestSetMilestoneInput { ...@@ -11569,7 +11569,7 @@ input MergeRequestSetMilestoneInput {
""" """
The milestone to assign to the merge request. The milestone to assign to the merge request.
""" """
milestoneId: ID milestoneId: MilestoneID
""" """
The project the merge request to mutate is in The project the merge request to mutate is in
...@@ -13389,7 +13389,7 @@ type Project { ...@@ -13389,7 +13389,7 @@ type Project {
""" """
The board's ID The board's ID
""" """
id: ID! id: BoardID!
): Board ): Board
""" """
...@@ -18789,7 +18789,7 @@ input TodoMarkDoneInput { ...@@ -18789,7 +18789,7 @@ input TodoMarkDoneInput {
""" """
The global id of the todo to mark as done The global id of the todo to mark as done
""" """
id: ID! id: TodoID!
} }
""" """
...@@ -18824,7 +18824,7 @@ input TodoRestoreInput { ...@@ -18824,7 +18824,7 @@ input TodoRestoreInput {
""" """
The global id of the todo to restore The global id of the todo to restore
""" """
id: ID! id: TodoID!
} }
""" """
......
...@@ -5106,7 +5106,7 @@ ...@@ -5106,7 +5106,7 @@
"name": null, "name": null,
"ofType": { "ofType": {
"kind": "SCALAR", "kind": "SCALAR",
"name": "ID", "name": "ListID",
"ofType": null "ofType": null
} }
}, },
...@@ -20666,7 +20666,7 @@ ...@@ -20666,7 +20666,7 @@
"name": null, "name": null,
"ofType": { "ofType": {
"kind": "SCALAR", "kind": "SCALAR",
"name": "ID", "name": "BoardID",
"ofType": null "ofType": null
} }
}, },
...@@ -26103,7 +26103,7 @@ ...@@ -26103,7 +26103,7 @@
"description": "The iteration to assign to the issue.\n", "description": "The iteration to assign to the issue.\n",
"type": { "type": {
"kind": "SCALAR", "kind": "SCALAR",
"name": "ID", "name": "IterationID",
"ofType": null "ofType": null
}, },
"defaultValue": null "defaultValue": null
...@@ -31753,7 +31753,7 @@ ...@@ -31753,7 +31753,7 @@
"description": "The milestone to assign to the merge request.\n", "description": "The milestone to assign to the merge request.\n",
"type": { "type": {
"kind": "SCALAR", "kind": "SCALAR",
"name": "ID", "name": "MilestoneID",
"ofType": null "ofType": null
}, },
"defaultValue": null "defaultValue": null
...@@ -39336,7 +39336,7 @@ ...@@ -39336,7 +39336,7 @@
"name": null, "name": null,
"ofType": { "ofType": {
"kind": "SCALAR", "kind": "SCALAR",
"name": "ID", "name": "BoardID",
"ofType": null "ofType": null
} }
}, },
...@@ -54608,7 +54608,7 @@ ...@@ -54608,7 +54608,7 @@
"name": null, "name": null,
"ofType": { "ofType": {
"kind": "SCALAR", "kind": "SCALAR",
"name": "ID", "name": "TodoID",
"ofType": null "ofType": null
} }
}, },
...@@ -54714,7 +54714,7 @@ ...@@ -54714,7 +54714,7 @@
"name": null, "name": null,
"ofType": { "ofType": {
"kind": "SCALAR", "kind": "SCALAR",
"name": "ID", "name": "TodoID",
"ofType": null "ofType": null
} }
}, },
...@@ -7,7 +7,7 @@ module Mutations ...@@ -7,7 +7,7 @@ module Mutations
graphql_name 'BoardListUpdateLimitMetrics' graphql_name 'BoardListUpdateLimitMetrics'
argument :list_id, argument :list_id,
GraphQL::ID_TYPE, ::Types::GlobalIDType[::List],
required: true, required: true,
description: 'The global ID of the list.' description: 'The global ID of the list.'
......
...@@ -6,7 +6,7 @@ module Mutations ...@@ -6,7 +6,7 @@ module Mutations
graphql_name 'IssueSetIteration' graphql_name 'IssueSetIteration'
argument :iteration_id, argument :iteration_id,
GraphQL::ID_TYPE, ::Types::GlobalIDType[::Iteration],
required: false, required: false,
loads: Types::IterationType, loads: Types::IterationType,
description: <<~DESC description: <<~DESC
......
...@@ -37,8 +37,7 @@ RSpec.describe 'Update list limit metrics' do ...@@ -37,8 +37,7 @@ RSpec.describe 'Update list limit metrics' do
it 'returns an error if the gid identifies another object' do it 'returns an error if the gid identifies another object' do
post_graphql_mutation(mutation('all_metrics', list_id: user.to_global_id.to_s), current_user: create(:user)) post_graphql_mutation(mutation('all_metrics', list_id: user.to_global_id.to_s), current_user: create(:user))
expect(graphql_errors).to include(a_hash_including('message' => "The resource that you are attempting to access does " \ expect(graphql_errors).to include(a_hash_including('message' => /"#{GitlabSchema.id_from_object(user)}" does not represent an instance of List/))
"not exist or you don't have permission to perform this action"))
end end
%w[all_metrics issue_count issue_weights].each do |metric| %w[all_metrics issue_count issue_weights].each do |metric|
......
...@@ -77,14 +77,14 @@ RSpec.describe 'Marking todos done' do ...@@ -77,14 +77,14 @@ RSpec.describe 'Marking todos done' do
context 'when using an invalid gid' do context 'when using an invalid gid' do
let(:input) { { id: GitlabSchema.id_from_object(author).to_s } } let(:input) { { id: GitlabSchema.id_from_object(author).to_s } }
let(:invalid_gid_error) { "\"#{input[:id]}\" does not represent an instance of #{todo1.class}" } let(:invalid_gid_error) { /"#{input[:id]}" does not represent an instance of #{todo1.class}/ }
it 'contains the expected error' do it 'contains the expected error' do
post_graphql_mutation(mutation, current_user: current_user) post_graphql_mutation(mutation, current_user: current_user)
errors = json_response['errors'] errors = json_response['errors']
expect(errors).not_to be_blank expect(errors).not_to be_blank
expect(errors.first['message']).to eq(invalid_gid_error) expect(errors.first['message']).to match(invalid_gid_error)
expect(todo1.reload.state).to eq('pending') expect(todo1.reload.state).to eq('pending')
expect(todo2.reload.state).to eq('done') expect(todo2.reload.state).to eq('done')
......
...@@ -77,14 +77,14 @@ RSpec.describe 'Restoring Todos' do ...@@ -77,14 +77,14 @@ RSpec.describe 'Restoring Todos' do
context 'when using an invalid gid' do context 'when using an invalid gid' do
let(:input) { { id: GitlabSchema.id_from_object(author).to_s } } let(:input) { { id: GitlabSchema.id_from_object(author).to_s } }
let(:invalid_gid_error) { "\"#{input[:id]}\" does not represent an instance of #{todo1.class}" } let(:invalid_gid_error) { /"#{input[:id]}" does not represent an instance of #{todo1.class}/ }
it 'contains the expected error' do it 'contains the expected error' do
post_graphql_mutation(mutation, current_user: current_user) post_graphql_mutation(mutation, current_user: current_user)
errors = json_response['errors'] errors = json_response['errors']
expect(errors).not_to be_blank expect(errors).not_to be_blank
expect(errors.first['message']).to eq(invalid_gid_error) expect(errors.first['message']).to match(invalid_gid_error)
expect(todo1.reload.state).to eq('done') expect(todo1.reload.state).to eq('done')
expect(todo2.reload.state).to eq('pending') expect(todo2.reload.state).to eq('pending')
......
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