16
I've created knex-graphql-utils, which optimizes your GraphQL server with PostgreSQL
I've created a tiny library which improves performance for GraphQL + Knex.
![](https://res.cloudinary.com/practicaldev/image/fetch/s--lenz8QMd--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://user-images.githubusercontent.com/10719495/126906832-f991dd7d-b563-4fa2-9313-738f476d46c8.png)
![](https://res.cloudinary.com/practicaldev/image/fetch/s--sCg3zhbV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://user-images.githubusercontent.com/10719495/126906862-71b456bd-82da-46d1-b6d3-acd1c3233885.png)
- Filter
select
columns based on a query from clients - Load relations without N+1 problem (pagination available!)
Currently only PostgreSQL is supported, but I'll support other RDBMS too if needed.
Creating a GraphQL service with a Relational Database is a hard thing. We should take care of:
- Performance for querying relations. N+1 problem will happen if you don't use Dataloader.
-
select *
make your server slow, but hard to filter columns based on requests. - Pagination. Dataloader pattern is hard to implement pagination without a hacky
union
or window functions.knex-graphql-utils
usesrow_number()
window function to do it.
As a developer, I noticed that I'm doing the same thing again and again - so I convert my work into a library.
The syntax is like this:
![](https://res.cloudinary.com/practicaldev/image/fetch/s--zcJ46L25--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rl8u4p6io98ds8pv6dhx.png)
Please try it! Any feedback is welcome.
16