At first, I didn't understand the question, because the point of graphql is to choose your data selectively... but then I realized that you want to send SQL queries to a single endpoint. And then I was confused! What is indeed the point of graphql (on a relational database, at any rate)?
It seems that the simplest reason is that graphql abstracts away the database, while SQL works only for querying the database directly. See here.
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.
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.
At first, I didn't understand the question, because the point of graphql is to choose your data selectively... but then I realized that you want to send SQL queries to a single endpoint. And then I was confused! What is indeed the point of graphql (on a relational database, at any rate)?
It seems that the simplest reason is that graphql abstracts away the database, while SQL works only for querying the database directly. See here.
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.
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.
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.
Can you point me to the source where they generate the SQL queries?
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...