Commit ca2e7ddc authored by Luke Duncalfe's avatar Luke Duncalfe

Update Discussion mutations to use new Global IDs

This changes the Discussion mutation to use the new `GlobalID` types for
arguments, with the temporary compatibility layer added in
https://gitlab.com/gitlab-org/gitlab/-/merge_requests/36209.

https://gitlab.com/gitlab-org/gitlab/-/issues/268042
parent 7a7095fa
...@@ -1281,7 +1281,6 @@ Graphql/IDType: ...@@ -1281,7 +1281,6 @@ Graphql/IDType:
- 'app/graphql/mutations/boards/create.rb' - 'app/graphql/mutations/boards/create.rb'
- 'app/graphql/mutations/boards/issues/issue_move_list.rb' - 'app/graphql/mutations/boards/issues/issue_move_list.rb'
- 'app/graphql/mutations/boards/lists/update.rb' - 'app/graphql/mutations/boards/lists/update.rb'
- 'app/graphql/mutations/discussions/toggle_resolve.rb'
- 'app/graphql/mutations/issues/update.rb' - 'app/graphql/mutations/issues/update.rb'
- 'app/graphql/mutations/metrics/dashboard/annotations/delete.rb' - 'app/graphql/mutations/metrics/dashboard/annotations/delete.rb'
- 'app/graphql/mutations/snippets/destroy.rb' - 'app/graphql/mutations/snippets/destroy.rb'
......
...@@ -8,7 +8,7 @@ module Mutations ...@@ -8,7 +8,7 @@ module Mutations
description 'Toggles the resolved state of a discussion' description 'Toggles the resolved state of a discussion'
argument :id, argument :id,
GraphQL::ID_TYPE, Types::GlobalIDType[Discussion],
required: true, required: true,
description: 'The global id of the discussion' description: 'The global id of the discussion'
...@@ -54,7 +54,10 @@ module Mutations ...@@ -54,7 +54,10 @@ module Mutations
end end
def find_object(id:) def find_object(id:)
GitlabSchema.object_from_id(id, expected_type: ::Discussion) # TODO: remove explicit coercion once compatibility layer has been removed
# See: https://gitlab.com/gitlab-org/gitlab/-/issues/257883
id = Types::GlobalIDType[Discussion].coerce_isolated_input(id)
GitlabSchema.find_by_gid(id)
end end
def resolve!(discussion) def resolve!(discussion)
......
---
title: Update GraphQL discussionToggleResolve mutation input id to be more type-specific
merge_request: 45346
author:
type: changed
...@@ -5870,7 +5870,7 @@ input DiscussionToggleResolveInput { ...@@ -5870,7 +5870,7 @@ input DiscussionToggleResolveInput {
""" """
The global id of the discussion The global id of the discussion
""" """
id: ID! id: DiscussionID!
""" """
Will resolve the discussion when true, and unresolve the discussion when false Will resolve the discussion when true, and unresolve the discussion when false
......
...@@ -16105,7 +16105,7 @@ ...@@ -16105,7 +16105,7 @@
"name": null, "name": null,
"ofType": { "ofType": {
"kind": "SCALAR", "kind": "SCALAR",
"name": "ID", "name": "DiscussionID",
"ofType": null "ofType": null
} }
}, },
...@@ -50,8 +50,8 @@ RSpec.describe Mutations::Discussions::ToggleResolve do ...@@ -50,8 +50,8 @@ RSpec.describe Mutations::Discussions::ToggleResolve do
it 'raises an error' do it 'raises an error' do
expect { subject }.to raise_error( expect { subject }.to raise_error(
Gitlab::Graphql::Errors::ArgumentError, GraphQL::CoercionError,
"#{discussion.to_global_id} is not a valid ID for Discussion." "\"#{discussion.to_global_id}\" does not represent an instance of Discussion"
) )
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