0

I'm trying to update a trashed model, without having to restore it first.

Schema

extend type Mutation {
   updateAuthor(id: ID!, input: AuthorInput @spread, trashed: Trashed @trashed): Author @update @softDeletes
}

Mutation

mutation{
  updateAuthor(id: 1, trashed: WITH, input:{
    name: "William"
  }){
    id
    name
  }
}

Response

"No query results for model [App\\Author] 1"

This works fine if the Author 1 isn't softdeleted of course.

I saw in the PR here that it was only implemented for @all @find and @paginate. So I'm guessing it should still be added to the @update directive?

Gregory
  • 1,148
  • 1
  • 9
  • 24

1 Answers1

1

As first, you don't have to define @trashed directive in your schema manually, it is covered by @softModels directive.

And you are right, currently you are not able to manipulate soft deleted model. I actually didn't think about that usage. In my app, if entity is soft deleted it is in trash in user UI, and is actually not possible to come to the edit-page of the entity, if it in trash.

I opened an issue, you are free to take a part in discussion: https://github.com/nuwave/lighthouse/issues/1145

lorado
  • 336
  • 1
  • 7