3 ms·
GraphQL is inherently more complicated. It's one more step at a minimum, and more honestly two or three more steps. I can build an endpoint and point it straig
by andrewmcwatters 5y ago
GraphQL is inherently more complicated. It's one more step at a minimum, and more honestly two or three more steps.
I can build an endpoint and point it straight to a parameterized SQL query.
With GraphQL, I build an endpoint, and point it straight to a GraphQL... schema? And then I have to define where that data comes from, and then how to return it...
It's just professional negligence to suggest it's not more involved.
- crubier 5y agoThe 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).