DEV Community

Discussion on: GraphQL for PostgreSQL - Why?

Collapse
 
johanneslichtenberger profile image
Johannes Lichtenberger

Hm, I'm not completely convinced that it's adding a lot. I think SQL is the main query language for relational databases, and why restricting its power? :-) Basically each relational database driver exposes a JDBC API, which more or less wraps pure SQL queries.

Collapse
 
uminer profile image
Moshe Uminer

Agreed, if it is wrapping the database directly, as opposed to a service that might transform the database, I'm not sure how much it would add.

Thread Thread
 
benbot profile image
Benjamin Botwin • Edited

depending on the tools, you're not restricting the power of the DB, you're adding a thin and intelligent HTTP based layer on top of your DB.

Read into the docs (and code if you're into that) for postgraphile. They generate VERY efficient sql queries AND you can write query and mutation resolvers in postgresql so you maintain all the power of the database while getting a very nice graphql api to work with.

Another reason you may want a graphql layer on top of your DB would be for more control over your response payloads. You could get as little data as you need, which is a BIG win for mobile apps who's users have pretty small data caps.

Thread Thread
 
johanneslichtenberger profile image
Johannes Lichtenberger

Can you point me to the source where they generate the SQL queries?

Thread Thread
 
benbot profile image
Benjamin Botwin

I haven’t dug too deeply into postgraphile’s code, but I believe this is where they build their queries.

github.com/graphile/graphile-engin...