diff options
Diffstat (limited to 'app/graphql/mutations/boards/lists')
-rw-r--r-- | app/graphql/mutations/boards/lists/base_update.rb | 40 | ||||
-rw-r--r-- | app/graphql/mutations/boards/lists/create.rb | 2 | ||||
-rw-r--r-- | app/graphql/mutations/boards/lists/update.rb | 22 |
3 files changed, 42 insertions, 22 deletions
diff --git a/app/graphql/mutations/boards/lists/base_update.rb b/app/graphql/mutations/boards/lists/base_update.rb new file mode 100644 index 00000000000..b06cb3b1e32 --- /dev/null +++ b/app/graphql/mutations/boards/lists/base_update.rb @@ -0,0 +1,40 @@ +# frozen_string_literal: true + +module Mutations + module Boards + module Lists + class BaseUpdate < BaseMutation + argument :position, GraphQL::INT_TYPE, + required: false, + description: 'Position of list within the board.' + + argument :collapsed, GraphQL::BOOLEAN_TYPE, + required: false, + description: 'Indicates if the list is collapsed for this user.' + + def resolve(list: nil, **args) + if list.nil? || !can_read_list?(list) + raise_resource_not_available_error! + end + + update_result = update_list(list, args) + + { + list: update_result.payload[:list], + errors: update_result.errors + } + end + + private + + def update_list(list, args) + raise NotImplementedError + end + + def can_read_list?(list) + raise NotImplementedError + end + end + end + end +end diff --git a/app/graphql/mutations/boards/lists/create.rb b/app/graphql/mutations/boards/lists/create.rb index 673fa95fc56..590a905ab7b 100644 --- a/app/graphql/mutations/boards/lists/create.rb +++ b/app/graphql/mutations/boards/lists/create.rb @@ -34,4 +34,4 @@ module Mutations end end -Mutations::Boards::Lists::Create.prepend_if_ee('::EE::Mutations::Boards::Lists::Create') +Mutations::Boards::Lists::Create.prepend_mod_with('Mutations::Boards::Lists::Create') diff --git a/app/graphql/mutations/boards/lists/update.rb b/app/graphql/mutations/boards/lists/update.rb index 504082ec22c..d17dd5162a0 100644 --- a/app/graphql/mutations/boards/lists/update.rb +++ b/app/graphql/mutations/boards/lists/update.rb @@ -3,7 +3,7 @@ module Mutations module Boards module Lists - class Update < BaseMutation + class Update < BaseUpdate graphql_name 'UpdateBoardList' argument :list_id, Types::GlobalIDType[List], @@ -11,29 +11,11 @@ module Mutations loads: Types::BoardListType, description: 'Global ID of the list.' - argument :position, GraphQL::INT_TYPE, - required: false, - description: 'Position of list within the board.' - - argument :collapsed, GraphQL::BOOLEAN_TYPE, - required: false, - description: 'Indicates if the list is collapsed for this user.' - field :list, Types::BoardListType, null: true, description: 'Mutated list.' - def resolve(list: nil, **args) - raise_resource_not_available_error! unless can_read_list?(list) - update_result = update_list(list, args) - - { - list: update_result[:list], - errors: list.errors.full_messages - } - end - private def update_list(list, args) @@ -42,8 +24,6 @@ module Mutations end def can_read_list?(list) - return false unless list.present? - Ability.allowed?(current_user, :read_issue_board_list, list.board) end end |