Class: Mutations::Snippets::Destroy

Inherits:
Base
  • Object
show all
Defined in:
app/graphql/mutations/snippets/destroy.rb

Constant Summary collapse

ERROR_MSG =
'Error deleting the snippet'

Constants inherited from BaseMutation

BaseMutation::ERROR_MESSAGE

Instance Method Summary collapse

Methods inherited from BaseMutation

#api_user?, #current_user, #errors_on_object, #ready?

Instance Method Details

#resolve(id:) ⇒ Object


15
16
17
18
19
20
21
22
23
24
# File 'app/graphql/mutations/snippets/destroy.rb', line 15

def resolve(id:)
  snippet = authorized_find!(id: id)

  response = ::Snippets::DestroyService.new(current_user, snippet).execute
  errors = response.success? ? [] : [ERROR_MSG]

  {
    errors: errors
  }
end