The 15 seconds and 10 lines of code you "loose" defining your graphQL schema saves you hours soon after, when you'll be fixing the problems created by poorly structured REST endpoint and endless debates.
With REST: I can build an endpoint and point it straight to a parameterized SQL query.
With GraphQL: I can build a resolver and point it straight to a parameterized SQL query.
So yes, I insist that it's overall much simpler to use GraphQL, having done both extensively.
Here is a GraphQL server in Python, (Note that it automatically provides documentation, a GraphQL interactive playground, Introspection, etc.). Do the same with Rest and tell me where the overhead is
from ariadne import QueryType, make_executable_schema
from ariadne.asgi import GraphQL
from starlette.applications import Starlette
type_defs = """
type Query {
projects(first: Int): [Project!]!
}
type Project {
id: Int
name: String
}
"""
query = QueryType()
@query.field("projects")
async def resolve_projects(_, info, first=10):
query = projects.select().limit(first)
results = await database.fetch_all(query)
return results
Starlette().mount(
"/graphql",
GraphQL(make_executable_schema(type_defs, query)),
)
(It could be made even shorter with Graphene, but shorter != better in my opinion).