zach.codes

Share this post

User's avatar
zach.codes
Filtering with Prisma and GraphQL
Copy link
Facebook
Email
Notes
More

Filtering with Prisma and GraphQL

Zach Silveira
Jan 01, 2021
∙ Paid

Share this post

User's avatar
zach.codes
Filtering with Prisma and GraphQL
Copy link
Facebook
Email
Notes
More
Share
Filtering with Prisma and GraphQL

Since it's New Year's day, I decided to start it off productively. In this post you'll learn my approach to filtering through tables using Prisma and Apollo Server. It shows how simple prisma is, and how little code is required to represent some pretty lengthy sql statements under the hood.

Prelude

I'm rebuilding an application that has a listing page with a lot of complicated filter requirements.

For instance, there's a users table. Users have cases. Cases have types. The UI requires filtering by the case type on the user list. So, we've got

users
cases
types	

Three different tables, all we want is users who have at least one case with a certain type to show up in our listing page.

This is an annoying sql query if you're manually writing it. You have to grab users and join the cases, and join where at least one of the cases has the matching case type. I'm new to Postgres, and used MySQL for years before that, but even still, I can't write that query without a few quick googles. Writing SQL…

Keep reading with a 7-day free trial

Subscribe to zach.codes to keep reading this post and get 7 days of free access to the full post archives.

Already a paid subscriber? Sign in
© 2025 Zach Silveira
Privacy ∙ Terms ∙ Collection notice
Start writingGet the app
Substack is the home for great culture

Share

Copy link
Facebook
Email
Notes
More