Package for GraphQL filters?

This is more of a GraphQL question than a redwood-specific question, but perhaps someone has dealt with this already…

Hasura provides some great GraphQL filters out of the box, allowing limit, offset, order by, and some fairly complex where filters.

Conversely, the generated queries available by default from redwood are quite limited. Is anyone aware of a GraphQL package that I could use to quickly generate some/all of the extra functionality that a Hasura api provides?

Hi @mattsears18 Hasura really sits atop Postgres much like https://www.graphile.org/postgraphile/ does or even Supabase’s GraphQL implementation pg_graphql pg_graphql: A GraphQL extension for PostgreSQL.

In RedwoodJS, your GraphQL server isn’t limited to connecting to a database – and in RW you don’t have to use Postgres (you can use MySQL or MongoDB or PlanetScale, etc).

Your GQL server maps to services – and each service is response to “do some work”. It could be to query a Postgres database with Prisma – or it could fetch data from Redis or fetch data via a third party api.

So, the idea of adding postgres-database-like filters to the graphQL server here may not be approrpriate - since it is tightly coupled.

Also, in this approach you are exposing much of your database structure and info to to the client.

I think you’ll find that Prisma offers many of the same filters and options.

Now – could Redwood come bundles with some types or utilities to make this easier – especially in the case of paginating data and other common filtering tasks – yes, most definitely.

Happy to explore your needs and see where the framework an do some more heavy lifting here.

I make a lot of data tables. Tables with the types of sorting and filtering UI shown here and here. I can build a data table component that can generate the GraphQL queries, with paginating, filtering, and sorting, but I can’t send those queries to my redwood api without writing a ton of code in my redwood services. I can certainly do everything that I need with Hasura or Supabase, but I’m wondering if there might be a package or some type of middleware that can auto-generate the paginating, filtering, and sorting logic in my redwood services using Prisma.

1 Like