2 ms·
The problem is you might end up writing strange endpoints just to satisfy a specific UI page. For example, take a small blog, that holds several posts, each wi
by ar_lan 6y ago
The problem is you might end up writing strange endpoints just to satisfy a specific UI page.
For example, take a small blog, that holds several posts, each with an author.
In GraphQL, you could fetch all the posts, and all info related to the author in the same query (without any new, funny business).
In REST, if you wanted this in a single query, you'd need to define some endpoint like /post-and-authors-list that fetches all the posts and complete author information for each post, whereas most REST implementations would probably involve a small set of CRUD steps on all posts, and then several queries to fetch each author for further information as well (based on the author ID in the post).
So it's not that REST can't implement anything GraphQL wants to implement, but there is a lot more work involved, is harder to scale out with developers, etc.