Skip to content
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(SortPlugin): amend sorting to all fields #541

Merged
merged 3 commits into from
Aug 2, 2023

Conversation

flamerohr
Copy link
Contributor

@flamerohr flamerohr commented Jul 4, 2023

Fix sorting to all fields in the args.

This is because in framework DataList each call to ->sort() actually resets previous sorts made, and the result is that only the end sort happens.

Issue

@GuySartorelli
Copy link
Member

Thank you for this. This feels like something which ought to be tested. Could you please add a unit test to validate the sort args are being correctly applied?

@flamerohr
Copy link
Contributor Author

is an existing unit test for this plugin I can start writing the tests on? I'm not familiar enough with the test setup to jump right in

@GuySartorelli
Copy link
Member

Looks like IntegrationTest class in tests/Schema/IntegrationTest.php has a testFilterAndSort() method which is probably an appropriate place for this. There are also some pre-existing test schemas with sorts applied:
https://github.com/search?q=repo%3Asilverstripe%2Fsilverstripe-graphql+sort+path%3A%2F%5Etests%5C%2F%2F&type=code

@flamerohr flamerohr force-pushed the sort-all-fields branch 3 times, most recently from dc6d128 to 978ad1a Compare July 7, 2023 01:22
@flamerohr
Copy link
Contributor Author

@GuySartorelli test added, the diff looks a bit weird because I needed to tweak the other tests to accomodate to a third row added to the db

@GuySartorelli
Copy link
Member

Looks good, thank you!

@GuySartorelli GuySartorelli merged commit ca0b864 into silverstripe:4.3 Aug 2, 2023
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants