3 ms·
We’re experimenting with it on a new product at my company, and this is how we use it. Specifically, we use it as an API gateway in front of a bunch of restful
by yashap 8y ago
We’re experimenting with it on a new product at my company, and this is how we use it. Specifically, we use it as an API gateway in front of a bunch of restful services.
Another benefit is a more robust type system than you get with JSON. GraphQL supports union types, interfaces, etc., allows you to provide more strongly typed contracts between the backend and frontend.
One downside though - while the responses can become smaller, with fewer round trips, the requests get A LOT bigger (than with REST), as you have to specify every field, subfield, etc. This is especially true if you make heavy use of union types - then you have to specify all the fields, sub fields, etc. of all the various concrete members you might get back. Like requests with payloads over 1KB is not uncommon. If you’re polling, and the result of the polling is generally an empty response, you may end up sending significantly MORE data over the wire, not less.
- slitchfield 8y agoIf you're sending large requests polling for an empty response most of the time, that might be a good use case for a custom directive.