GraphQL is a declarative data fetching spec that is invented by Facebook and open sourced in 2015. GraphQL uses a special language called query language which looks a lot like JSON objects. GraphQL is an alternative to REST API’s and have following benefits:
- GraphQL query string is sent to GraphQL server and instead of getting full response from server you only get the data that is needed by you.
- Query is nested and data is requested at once on single endpoint while in REST there are multiple requests on different endpoints.
- Backward compatible (new fields can be added without breaking anything and old fields can continue to function)
- Can wrap around existing API