Graphql sort and filter

I understand that currently sorting and filtering is not implemented in graphql.
I want to ask then, why? Without these features Graphql is almost not usable.
It is not fare then to declare that you support Graphql…

I might be wrong but as far as I know GraphQL itself does not have a specific syntax dedicated to describe sort or filter semantics so it’s perfectly fair to say that FaunaDB supports GraphQL. If a GraphQL provider does support filters it’s often by passing custom parameter objects.

We do offer basic filtering.

However, regarding filters it’s not entirely true what you said.
we can do exact matches so saying that we do not offer filtering is not entirely correct.


Disclaimer: this is my personal opinion, I don’t think there is an official statement for the reason except that do not have an implementation ready yet to support arbitrary filters and/or sorting.

Filtering is indeed limited at this point as you can’t do complex and/or statements.
You can however escape to FQL at that point and do what you want via UDFs and bindings so it makes sense to release it already and be clear of what we can do and how to escape to FQL to access more advanced features.

It’s not entirely fair to say that it’s not usable since many users show that they can build fairly complex applications without these features (or they find their way to FQL to implement the custom behaviour). You are right that our GraphQL offering can still become far more powerful but bear in mind that FaunaDB is a scalable database and is pay-as-you-go. That means we should avoid to give devs a gun to shoot themselves in the foot. A database that’s not cloud-based or not meant for massive scale or is not pay-as-you-go could choose to just do the query, whether it’s efficient or not and accept the significant load on your servers and/or fail if it becomes to slow and/or charge you for the inefficiency.

In FaunaDB, the idea is that your queries are backed by indexes (and this is mandatory), arbitrary filtering would require us to set up these indexes for you in some way (either by specifying them in the schema via directives or by analysing the basic schema). What I’m saying is, if you want to make sure that your customers don’t have surprised then it’s a slightly more complex . :slight_smile:.

That said, it’s definitely something that we plan to work on.

What is the current status on GraphQL and filtering, limiting capabilities? I’m asking because now FQL has Range and other functions and probably GraphQL can take advantage. But do we have to write our own custom resolvers?



compare with FaunaDB:

In addition to Hasura examples, Prisma offers great ways see for example:

const result = await prisma.user.findMany({
  where: {
    email: {
      endsWith: '',
    posts: {
      some: {
        published: true,

See here for the specs: Filtering (Reference) | Prisma Docs