add.rb 768 B

123456789101112131415161718192021222324
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. module Gql::Mutations
  3. class User::Add < BaseMutation
  4. description 'Add a new user.'
  5. argument :input, Gql::Types::Input::UserInputType, description: 'The user data'
  6. argument :send_invite, Boolean, description: 'Wether invitation is sent to the new user', required: false
  7. field :user, Gql::Types::UserType, description: 'The created user.'
  8. def self.authorize(_obj, ctx)
  9. ctx.current_user.permissions?(['admin.user', 'ticket.agent'])
  10. end
  11. def resolve(input:, send_invite: false)
  12. user = Service::User::AddInternal
  13. .new(current_user: context.current_user)
  14. .execute(user_data: input.to_h, send_invite:)
  15. { user: }
  16. end
  17. end
  18. end