Problem/Motivation
I've been playing around this the JSON:API module in D9 using the Umami Profile to have some content to query against. I noticed that when sorting by title on node queries they are not being returned in the correct alphabetical order (at least as I understand it).
For instance: /jsonapi/node/recipe?sort=title
returns the list of recipes in the following order:
- Vegan chocolate and nut brownies
- Crema catalana
- Thai green curry
- Deep mediterranean quiche
- Fiery chili sauce
- Gluten free pizza
- Super easy vegetarian pasta bake
- Victoria sponge cake
- Watercress soup
interestingly, sorting in the reverse order with: /jsonapi/node/recipe?sort=-title
seems to return the correct order:
Actually the reverse order is off as well. "Deep mediterranean quiche" should be above "Crema catalana" and "Gluten free pizza" should be above "Fiery chili sauce"
- Watercress soup
- Victoria sponge cake
- Vegan chocolate and nut brownies
- Thai green curry
- Super easy vegetarian pasta bake
- Fiery chili sauce
- Deep mediterranean quiche
- Gluten free pizza
- Crema catalana
the same thing appears to be happening on other content types such as articles: /jsonapi/node/article?sort=title
I'm using Umami as an example but I assume there is nothing particular about the Umami profile that is causing the issue.
Steps to reproduce
- Install Drupal 9 with the Umami Profile.
- Enable the JSON:API module and any associated modules.
- Got to the url:
/jsonapi/node/recipe?sort=title
Expected Order:
- Crema catalana
- Deep mediterranean quiche
- Fiery chili sauce
- Gluten free pizza
- Super easy vegetarian pasta bake
- Thai green curry
- Vegan chocolate and nut brownies
- Victoria sponge cake
- Watercress soup
Actual Order:
- Vegan chocolate and nut brownies
- Crema catalana
- Thai green curry
- Deep mediterranean quiche
- Fiery chili sauce
- Gluten free pizza
- Super easy vegetarian pasta bake
- Victoria sponge cake
- Watercress soup
Proposed resolution
So far:
Get the language_code in EntityResource.php
's getCollectionQuery
method and pass to entity query
Remaining tasks
Review
User interface changes
N/A
API changes
N/A
Data model changes
N/A