Graphql and Rest - Comparison Notes
Intro
Personally, I have zero experience on the topic of GraphQL whereas I've developed and coded against REST APIs for Dogfooding usecases at work. This is a living document, and updates on the content are noted as separate paragraphs.
This rant here is a nice summary of the various pain points of the GraphQL method.
TL;DR
- Authorization
- Rate limiting
- Query parsing
- Data fetching and the N+1 problem,
- Authorization and the N+1 problem
Looks like the defenses against the above problems are not that efficient and justifies the pain of the author given his experience and adherence to GraphQL in the past.
So the alternative are
- OpenAPI 3.0+ compliant JSON REST API.
- Specification first GraphQL; but it does not specify how we'd alleviate the above seen concerns
HN says
Notes from related HackerNews thread
- mRPC and REST are just more straightforward to monitor, log, cache, authorize and debug.
Aside - automate HN summary
$$("td[indent='0'] ~ td.default div.comment").map(t => t.textContent)
Can we use lunar indexing to get to interesting stuff?
separate to questions, statements and analysis summaries; urls
Update 09 July '24
My recent experiments with tRPC and Next.js was an entirely big paradigm shift. With concepts like Universal Cache on the query client, SWR, etc., global state management in React has been greatly simplified. You might not need Redux. So, I think with respect to type safety and type hints for the server resources on client side, the 'mono-repoistic' approach of Next.js along with tRPC is a great win over the alleged complexities of GraphQL (on a smaller scale)
With Next.js' ServerActions, they say that tRPC can be done away with; but IMO, tRPC is a much more general technology which can be used in other frameworks as well. So its tRPC for the time being.
The only concern with tRPC is that the APIs generated by it are opinionated, so it must be a bit of a hassle for an OpenAPI'istic flavor of tRPC (I may be wrong here)
Update on 17 July '24
More people are talking about this. https://www.magiroux.com/eight-years-of-graphql is a equally rational argument about the problem. Gems, and how do they articulate!