-
-
Notifications
You must be signed in to change notification settings - Fork 438
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement support for querying soft deleted elements #937
Conversation
Nice feature, you did a great job with the implementation. I am still pondering on the best way to add a trashed filter to a query. We could do it through a schema-manipulating field directive, such as: foos(): [Foo!]! @all @softDeletes |
Thanks!
I was also thinking about it. But as people already discussed here I thought it is the idea people would like =) Currently solution is simple, but it might be not really clear, that adding I didn't write a custom directive till now, so don't know how would I implement your solution... |
The |
…_queries # Conflicts: # CHANGELOG.md
…o support_soft_delete_queries # Conflicts: # CHANGELOG.md
Ok, I'll give a try today ;) |
So, just got ready new implementation via directives. Actually this approach is much better, as we don't have to duplicate code and take care of, where this parameter could also be entered (e.g. on relation fields). By now it works also with One thing took me much time... I didn't figure out, why is it happened... As I updated my tests, I had something like this: $this->graphQL('
{
users {
tasks(trashed: ONLY) {
id
name
}
}
}
')->assertJson(...);
$this->graphQL('
{
users {
tasks(trashed: WITH) {
id
}
}
}
')->assertJsonCount(3, 'data.users.0.tasks') As you can see, these queries are different - different What helped - using aliases in graphql Query. This way results were always fetched correctly. I don't know, if this bug also appear in real world, we will see... |
@spawnia Should I do anything else, so this PR gets merged? I am trying to keep it all the time up to date... Would be nice if this feature could be released next week. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made changes as you wanted
P.s. First time in this situation on github. Was not sure what happens, when I click on "submit" :D
Hey @lorado working it in right now. I am changing the behaviour when using the directives upon models that do not |
The issue with multiple queries in a single test is caused by some caching mechanism within Laravel's HTTP helpers. It should not happen in production, as PHP dies after each request. |
Oh ok. Yea, I guessed that there is somewhere cache, but didn't know which one. Thanks for explanation. Your changes looks great. I was also thinking about throwing an exception, but was not sure if it is a good idea. |
Offtopic. Just for me to know how to work with github PR: Is it possible somehow to pull your changes you made in this PR? |
You can just pull them. I committed to your branch. |
@lorado can you hop into Slack for a quick chat? https://join.slack.com/t/lighthouse-php/shared_invite/enQtMzc1NzQwNTUxMjk3LWI1ZDQ1YWM1NmM2MmQ0NTU0NGNjZWFkMTJhY2VjMDAwZmMyZDFlZTc1Mjc3ZGY0MWM1Y2Q5MWNjYmJmYWJkYmU |
…_queries # Conflicts: # docs/master/sidebar.js
Related Issue/Intent
Resolves #100
Changes
Trash
is defined. Possible values areONLY
,WITH
andWITHOUT
@find
,@all
and@paginate
directives searches for argument of enum typeTrash
and applies defined filter to fetch eitheronlyTrashed
,withTrashed
orwithoutTrashed
Breaking changes
There are no breaking changes
Additional Note
I currently implemented this feature only for
@find
,@all
and@paginate
directives. I guess that probably it would be cool to be able to define such an argument on related items too? Didn't look for the possible implementation, but what you think?UPDATE
Reworked to
@softDeletes
directive, #937 (comment)