News for hackers. Stuff that matters.
Re:We Ditched REST and Went with GraphQL: Here’s Why by nforgerit on Sunday March 19, 2023 @02:18AM (#35216515)
Had to double-check this post's date since it feels like it was from five years ago with barely anything new. But good choice, IMHO!

I'm a fan of GraphQL. It serves as an excellent BFF framework for performant frontends. You get types, tooling, conventions for free and if you use something like Apollo GraphQL Client, it normalizes GraphQL responses and caches the individual entities.

In addition, I realized in the last 5 years how it helped managing product teams. There were teams with die hard frontend devs that practically annoyed me every day with requests for new/changed endpoints; once I got very pi*ed, implemented a GraphQL backend and gave them the GraphiQL UI such that they could discover and query the data themselves. Saved me a lot of frustration and was fun for them.

You can theoretically do the same with REST but if you dogmatically stick to Entities-Resources, it will not be performant if you have lists with nested sub-fetch (e.g. a list of blogposts with their author and her name/avatar). If you start creating endpoints which return a whole ViewModel, you're IMHO starting to leave RESTland and if you're doing it right, will eventually re-create something GraphQL-ish.

Re:We Ditched REST and Went with GraphQL: Here’s Why by alexgrover on Sunday March 19, 2023 @02:29AM (#35216557)
All of those problems and solutions are not unique to either tech choice. You can use OpenApi for documentation, a variety of libraries like React-query for caching, and N+1 issues exist (and are arguably more complicated to solve) in graphql.
Re:We Ditched REST and Went with GraphQL: Here’s Why by eurasiantiger on Sunday March 19, 2023 @07:15AM (#35217873)
N+1 issues do not exist when using a graph datastore which supports GraphQL.
Re:We Ditched REST and Went with GraphQL: Here’s Why by alexgrover on Sunday March 19, 2023 @08:13AM (#35218210)
Many/most people don’t though. Dataloader libraries exist for a reason.
Re:We Ditched REST and Went with GraphQL: Here’s Why by zihotki on Sunday March 19, 2023 @08:29AM (#35218297)
This statement is false. N+1 issues may exist even in that case. It may vary what caused it and what are the options to solve it.
Re:We Ditched REST and Went with GraphQL: Here’s Why by eurasiantiger on Sunday March 19, 2023 @09:18AM (#35218638)
Sure, they will exist if someone intentionally codes them in. But not when fetching data is done in one pass.