This question does not make much sense: a GraphQL API can an often is implemented with SQL !
You could ask: why graphql instead of RESTful?
You could ask: why graphql instead of RESTful?
{ project(name: "GraphQL") { tagline } }
Better than select tagline from project where name = "GraphQL"
Especially if the GraphQL server is just an intermediary later that ends up being translated to SQL anyway.That real answer to the parent's question is that most people don't have confidence in SQL servers's access controls.
What if I want/need Cassandra, ElasticSearch or MongoDB? An SQL DB is just one place where you have data and there are very valid reasons for using other solutions.
In fact, some people might argue that you want to do everything with event sourcing / kappa and use Kafka + specialised data stores.
GraphQL fits this universe perfectly. It also fits the one where you only use a single SQL DB since a GraphQL query translates quite nicely to SQL with minimal amount of code in between.
{
project(name: "GraphQL") {
tagline
authors {
name
friends {
name
}
}
}
}