DEV Community

[Comment from a deleted post]
Collapse
 
tomasforsman profile image
Tomas Forsman

Explain to me like I'm a total newbie (almost true).

Why is graphql a better option, for a small/medium sized application, than simply sending the result of a SQL statement as json?

Collapse
 
andrewbrown profile image
Andrew Brown πŸ‡¨πŸ‡¦

GraphQL makes sense for Github because they have a public API with user demand for data-structures in great variation in returned data.

If you're small or medium you are much better off not dealing with GraphQL at all because it's much easier to work and maintain queries than it is dealing with GraphQL.

If you're using something such as postgres they have amazing JSON functions so you directly return JSON straight from the database.

Collapse
 
mvoloskov profile image
Miloslav πŸ³οΈβ€πŸŒˆ πŸ¦‹ Voloskov
  1. Adjustability. If you have a very rich data model, for example, if one order of your e-shop must return the full thing when you need it and just order id and order date for the orders list.
  2. Multiple sources. For example, you may want to have Cassandra DB for analytics (cheap writes, expensive reads) and some SQL DB for everything else (cheap reads, expensive writes) and want to assemble this all to provide some unified API

Aside from that, GraphQL just reduces the amount of code you have to write, and less code means less bugs :)