-
Notifications
You must be signed in to change notification settings - Fork 61
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
FIX QuerySort::sort method should support sorting for multi arguments #562
FIX QuerySort::sort method should support sorting for multi arguments #562
Conversation
176f29f
to
a713bd8
Compare
b3929c0
to
ef90d51
Compare
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.
This can't be MNT
since it's changing actual code that projects will be using.
If the changes in the QuerySort
class are fixing a bug, you should use FIX
and the commit message should explain what the bug is that's being fixed.
If they're just an enhancement, then use ENH
and the commit message should explain what the enhancement is.
ef90d51
to
2e5ca8f
Compare
The reason changing the order of the fields in the schema affected the results is because the underlying GraphQL library we're using ignores the order that fields are entered in the query arguments. It uses the order that the fields were defined in the schema. I've added a new commit on top of yours to resolve this. It also changes the test to use a query provider so it will run all of the FilterAndSort scenarios even if one fails. I removed the scenarios that had commented out tests because they weren't actually contributing anything to the test coverage. Normally I would have asked you to make those changes, but I didn't know what changes were necessary or even possible - and to find that out I had to essentially do the full implementation. At that point it was just easier to commit that implementation rather than ask you to redo what I had just done. Next steps
|
Please also check if this bug affects graphql 4 - if so, we need to retarget to |
Open new PR for 4.3: |
Description
Even if a method receives several parameters, then sorting occurs by the field of the arguments that is last specified in the schema, and not in the passed parameters. That is, if
SilverStripe\GraphQL\Tests\Fake\DataObjectFake
has the following schemaand sorting is required
AuthorID => DESC, myField => ASC
, then sorting was done only byAuthorID
, since in the schema this field is indicated after myField.Therefore, the call
$list->sort()
must be completed after all the necessary processing has been carried out.Parent issue