summaryrefslogtreecommitdiff
path: root/app/graphql/mutations/boards/create.rb
blob: 080bf7c6e79daeae5db57a92809777a4e4fb0db1 (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
28
29
30
31
32
33
# frozen_string_literal: true

module Mutations
  module Boards
    class Create < ::Mutations::BaseMutation
      include Mutations::ResolvesResourceParent

      graphql_name 'CreateBoard'

      include Mutations::Boards::CommonMutationArguments

      field :board,
            Types::BoardType,
            null: true,
            description: 'Board after mutation.'

      authorize :admin_issue_board

      def resolve(args)
        board_parent = authorized_resource_parent_find!(args)

        response = ::Boards::CreateService.new(board_parent, current_user, args).execute

        {
          board: response.success? ? response.payload : nil,
          errors: response.errors
        }
      end
    end
  end
end

Mutations::Boards::Create.prepend_mod_with('Mutations::Boards::Create')