debian-mirror-gitlab/app/graphql/resolvers/boards_resolver.rb

33 lines
957 B
Ruby
Raw Normal View History

2020-03-09 13:42:32 +05:30
# frozen_string_literal: true
module Resolvers
class BoardsResolver < BaseResolver
type Types::BoardType, null: true
2020-04-08 14:13:33 +05:30
argument :id, GraphQL::ID_TYPE,
required: false,
description: 'Find a board by its ID'
def resolve(id: nil)
2020-03-09 13:42:32 +05:30
# The project or group could have been loaded in batch by `BatchLoader`.
# At this point we need the `id` of the project/group to query for boards, so
# make sure it's loaded and not `nil` before continuing.
parent = object.respond_to?(:sync) ? object.sync : object
return Board.none unless parent
2020-04-08 14:13:33 +05:30
Boards::ListService.new(parent, context[:current_user], board_id: extract_board_id(id)).execute(create_default_board: false)
rescue ActiveRecord::RecordNotFound
Board.none
end
private
def extract_board_id(gid)
return unless gid.present?
GitlabSchema.parse_gid(gid, expected_type: ::Board).model_id
2020-03-09 13:42:32 +05:30
end
end
end