Saturday, November 16, 2019

GraphQL

REST is a software architecture that defines a set of constraints to be used for creating web services, Introduced in the year 2000.
Whereas GraphQL is a data query and manipulation language for APIs, and runtime to fulfill queries with existing data, developed by Facebook in 2011.
The following Image shows the Timeline/Journey from RPC to GraphQL
Advantages of Graphql over REST
  • Resolves over-fetching and under-fetching
Apps Using REST APIs results in over-fetching as well as under-fetching because of the entire data in that endpoint will be returned in the JSON format. This causes performance and scalability issues.
Whereas GraphQL with its queries, schemas, and resolvers enable developers to design API call only specific data requirement, This resolves Over-fetching and Under-fetching challenges.
  • Faster product Iterations on the frontend
When designing REST APIs, It can be a bottleneck when it comes to faster or quick iterations on the frontend. The reason behind this is because of REST APIs design endpoints according to the views in the application.
With GraphQL, Developers can write queries specifying their data requirement, and the iterations for developing frontend can continue without having to change the backend
  • GraphQL enables better analytics on the backend
Apps that use REST APIs get entire data in an endpoint, using this application owner can’t gain insights on the usage of specific data elements since the entire data is returned every time.
On the other hand, GraphQL uses resolvers, and they implement particular fields in a type. That way Application owner can track the performance of the resolvers, and find out whether the systems need performance tuning.
  • The Advantages of the GraphQL schema
GraphQL uses Schema Definition Language (SDL), The schema includes all the types used in an API, It defines how a client should access data on the server. After defining schema by the developers, Both the front and backend teams work parallel as they know the structure of the data. This helps to improve the productivity of the team.
Drawbacks of REST API?
The problem with REST APIs is they have multiple endpoints. These require round-trips to get the data. Every endpoint represents a resource, If we need data from multiple resources, It requires multiple round-trips to get the data. The language needed to request is very limited in the REST API.
In REST there is a problem of over-fetching, for example: If a client wants to select a specific record in the resource, the REST API will always fetch all of the fields irrespective of the client’s needs. It is over usage of network and memory resources but both client-side as well as server-side
Data fetching with GraphQL vs REST
The Typical usage of REST API will fetch data by calling multiple API endpoints, and the server will return all the data in those endpoints.
GraphQL uses queries, schema, and resolvers. Developers can specify the exact data they need, they can even create and execute nested queries.
GraphQL proves to be very useful where it comes to fetching data that satisfies the given condition. Example:- Instead of requesting all the students in the school, you can specifically ask for the students of a particular batch.

3 comments:

  1. I need to thank you for this very good read and I have bookmarked to check out new things from your post. Thank you very much for sharing such a useful article and Will definitely save and revisit your site.

    Hire GraphQL Developer India

    ReplyDelete
  2. Bipin Gupta: Graphql >>>>> Download Now

    >>>>> Download Full

    Bipin Gupta: Graphql >>>>> Download LINK

    >>>>> Download Now

    Bipin Gupta: Graphql >>>>> Download Full

    >>>>> Download LINK gJ

    ReplyDelete
  3. Bipin Gupta: Graphql >>>>> Download Now

    >>>>> Download Full

    Bipin Gupta: Graphql >>>>> Download LINK

    >>>>> Download Now

    Bipin Gupta: Graphql >>>>> Download Full

    >>>>> Download LINK al

    ReplyDelete