4 ms·
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 s
by nforgerit 4y ago
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.
- alexgrover 4y agoAll 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.
- eurasiantiger 4y agoN+1 issues do not exist when using a graph datastore which supports GraphQL.
- alexgrover 4y agoMany/most people don’t though. Dataloader libraries exist for a reason.
- zihotki 4y agoThis 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.
- eurasiantiger 4y agoSure, they will exist if someone intentionally codes them in. But not when fetching data is done in one pass.