We're using Hot Chocolate 14. .Net + EF Core 8, and PostgreSQL 13... I'd like to build a custom sort convention... but I haven't found any examples after scouring the internet.
The first example is actually mentioned as a teaser in the Hot Chocolate Docs without the example to support it... and that's NULLS_FIRST... (PostgreSQL sorts ASC nulls last by default).... however, EF Core NPGSQL doesn't support the PostgreSQL NULLS FIRST operation (see here) so I'm not sure that I can write something in Hot Chocolate that will get translated to the DB SQL properly.
So the next option / example would be to allow a boolean expression to be sent via GQL to HC... have it translated to the Order By predicate in EF Core, and that will correctly put it in the Order by SQL statement. So something like this... (note... I want NULLs first.. but PostgreSQL sorts FALSE > TRUE in ASC order.. so I have to reverse my logic here)
query getEntities {
entities(
order: [
{entity_status: {neq: null}} # this would be the magic
{entity_status: ASC}
]
) {
id_entity
entity_status
}
}
It would be translated to something like...
dbcontext.entity
.OrderBy(x => x.entity_status != null)
.ThenOrderBy(x => x.entity_status)
Which should then turn into
select id_entity, entity_status
from entity
order by entity_status is not null, entity_status;
Is this possible?