diff options
Diffstat (limited to 'app/graphql/resolvers/boards_resolver.rb')
-rw-r--r-- | app/graphql/resolvers/boards_resolver.rb | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/app/graphql/resolvers/boards_resolver.rb b/app/graphql/resolvers/boards_resolver.rb index 45c03bf0bef..eceb5b38031 100644 --- a/app/graphql/resolvers/boards_resolver.rb +++ b/app/graphql/resolvers/boards_resolver.rb @@ -4,7 +4,11 @@ module Resolvers class BoardsResolver < BaseResolver type Types::BoardType, null: true - def resolve(**args) + argument :id, GraphQL::ID_TYPE, + required: false, + description: 'Find a board by its ID' + + def resolve(id: nil) # 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. @@ -12,7 +16,17 @@ module Resolvers return Board.none unless parent - Boards::ListService.new(parent, context[:current_user]).execute(create_default_board: false) + 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 end end end |