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:
- 'app/graphql/mutations/boards/create.rb'
- 'app/graphql/mutations/boards/issues/issue_move_list.rb'
- 'app/graphql/mutations/boards/lists/update.rb'
- 'app/graphql/mutations/discussions/toggle_resolve.rb'
- 'app/graphql/mutations/issues/update.rb'
- 'app/graphql/mutations/metrics/dashboard/annotations/delete.rb'
- 'app/graphql/mutations/snippets/destroy.rb'
......
......@@ -8,7 +8,7 @@ module Mutations
description 'Toggles the resolved state of a discussion'
argument :id,
GraphQL::ID_TYPE,
Types::GlobalIDType[Discussion],
required: true,
description: 'The global id of the discussion'
......@@ -54,7 +54,10 @@ module Mutations
end
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
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 {
"""
The global id of the discussion
"""
id: ID!
id: DiscussionID!
"""
Will resolve the discussion when true, and unresolve the discussion when false
......
......@@ -16105,7 +16105,7 @@
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "ID",
"name": "DiscussionID",
"ofType": null
}
},
......@@ -50,8 +50,8 @@ RSpec.describe Mutations::Discussions::ToggleResolve do
it 'raises an error' do
expect { subject }.to raise_error(
Gitlab::Graphql::Errors::ArgumentError,
"#{discussion.to_global_id} is not a valid ID for Discussion."
GraphQL::CoercionError,
"\"#{discussion.to_global_id}\" does not represent an instance of Discussion"
)
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