From c2367afbf57ebc65d5b78a743b5d6a91f0aece9f Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Mon, 24 Feb 2020 18:09:05 +0000 Subject: Add latest changes from gitlab-org/gitlab@master --- app/graphql/resolvers/boards_resolver.rb | 18 ++++++++++++++++-- app/graphql/types/group_type.rb | 6 ++++++ app/graphql/types/project_type.rb | 6 ++++++ 3 files changed, 28 insertions(+), 2 deletions(-) (limited to 'app/graphql') 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 diff --git a/app/graphql/types/group_type.rb b/app/graphql/types/group_type.rb index 9f3905000b2..699aa51e6c8 100644 --- a/app/graphql/types/group_type.rb +++ b/app/graphql/types/group_type.rb @@ -52,6 +52,12 @@ module Types null: true, description: 'Boards of the group', resolver: Resolvers::BoardsResolver + + field :board, + Types::BoardType, + null: true, + description: 'A single board of the group', + resolver: Resolvers::BoardsResolver.single end end diff --git a/app/graphql/types/project_type.rb b/app/graphql/types/project_type.rb index f89bd5575a3..1142459f6eb 100644 --- a/app/graphql/types/project_type.rb +++ b/app/graphql/types/project_type.rb @@ -185,6 +185,12 @@ module Types null: true, description: 'Boards of the project', resolver: Resolvers::BoardsResolver + + field :board, + Types::BoardType, + null: true, + description: 'A single board of the project', + resolver: Resolvers::BoardsResolver.single end end -- cgit v1.2.1