Welcome to mirror list, hosted at ThFree Co, Russian Federation.

board_resolver.rb « resolvers « graphql « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 637d690e4cdeadd39c06d904bc65a68521e8ede9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# frozen_string_literal: true

module Resolvers
  class BoardResolver < BaseResolver.single
    alias_method :parent, :synchronized_object

    type Types::BoardType, null: true

    argument :id, ::Types::GlobalIDType[::Board],
             required: true,
             description: 'The board\'s ID.'

    def resolve(id: nil)
      return unless parent

      ::Boards::BoardsFinder.new(parent, context[:current_user], board_id: extract_board_id(id)).execute.first
    rescue ActiveRecord::RecordNotFound
      nil
    end

    private

    def extract_board_id(gid)
      GitlabSchema.parse_gid(gid, expected_type: ::Board).model_id
    end
  end
end