2020-09-30 14:09:52 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Resolvers
|
|
|
|
class BoardResolver < BaseResolver.single
|
2021-03-18 02:11:52 -04:00
|
|
|
alias_method :parent, :object
|
2020-09-30 14:09:52 -04:00
|
|
|
|
|
|
|
type Types::BoardType, null: true
|
|
|
|
|
2020-10-16 08:09:33 -04:00
|
|
|
argument :id, ::Types::GlobalIDType[::Board],
|
2020-09-30 14:09:52 -04:00
|
|
|
required: true,
|
2021-08-17 20:11:18 -04:00
|
|
|
description: 'ID of the board.'
|
2020-09-30 14:09:52 -04:00
|
|
|
|
|
|
|
def resolve(id: nil)
|
|
|
|
return unless parent
|
|
|
|
|
2021-03-05 04:09:07 -05:00
|
|
|
::Boards::BoardsFinder.new(parent, context[:current_user], board_id: extract_board_id(id)).execute.first
|
2020-09-30 14:09:52 -04:00
|
|
|
rescue ActiveRecord::RecordNotFound
|
|
|
|
nil
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def extract_board_id(gid)
|
|
|
|
GitlabSchema.parse_gid(gid, expected_type: ::Board).model_id
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|