Class: Mutations::DeleteMutation

Inherits:
BaseMutation show all
Defined in:
app/graphql/mutations/delete_mutation.rb

Instance Method Summary collapse

Methods inherited from BaseMutation

argument, resource_class

Instance Method Details

#resolve(id:) ⇒ Object


8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'app/graphql/mutations/delete_mutation.rb', line 8

def resolve(id:)
  object = load_object_by(id: id)
  authorize!(object, :destroy)

  User.as(context[:current_user]) do
    errors = if object.destroy
               []
             else
               map_errors_to_path(object)
             end

    {
      id: id,
      errors: errors,
    }
  end
end