Hacker News new | ask | show | jobs
by switch007 1759 days ago
> Avoid multiple round trips: Often, in order to call one endpoint that required a certain parameter, such as /getProfileById/{id}, we would have to call additional endpoints as a pre-req, such as getUser{username} to returnparameters such as id. This was a problem because we were making multiple round trips to fetch one piece of information. GraphQL helped solve this problem because it allowed us to fetch everything we need in one round trip.

Why not add another URL? /getProfileByUsername?

Nothing stops you building another layer of endpoints to service your frontend.

2 comments

I read this as user & profile are two separate resources. With a standard REST API, calls are tied to a specific resource.

> Nothing stops you building another layer of endpoints to service your frontend.

They could've added a new endpoint for that specific usecase but I'm assuming they've simplified their actual needs to this one example.

Why not use /getProfile?id=something in the first place?