Sunday, 27 March 2022

GraphQL

 GraphQL is a query language for your API.

It has been developed as a more flexible and efficient alternative to REST.


GraphQL - Query language for API


1.Provides clients the power to ask for exactly what they need and nothing more.

2.GraphQL APIs get all the data your app needs in a single request.

3.Language agnostic - Plenty of client and server libraries are avaialble.



Note :

In GraphQL we can compose the request in the form of a GraphQL query and ask

for exactly what I need to build the app.It then responds with the JSON object with exactly what I asked for.


No multiple round-trips like REST. No Over-fetching or under-fetching.


REST vs GraphQL :


REST :

1.Multiple round trips to collect the information form multiple resources.

2.Over fetching and under fetching data resources.

3.Frontend teams rely heavily on backend teams to deliver the APIs.

4.Caching is built into HTTP spec.


GraphQL :

1.One single request to collect the information by aggregation of data.

2.you only get what you ask for.Tailor made queries to your exact needs.

3.Frontend and backend teams can work independently.

4.Doesn't use HTTP spec for caching (Libraries like APollo,Relay come with caching options).


No comments:

Post a Comment