Search

Treatise On Graphql

Updated: Aug 27, 2021





Straight Stuff About Graphql

As We All Know, Before Graphql It Was REST. Now Why Graphql ?

As a front end web developer you may have heard of Graphql or even may use it now. But what is it?


In a simple way as someone said we can say Grpahql do the “REST”


A Query Language For API

Graphql is a query language for API. I will explain in a simple way. A new way to fetch APIs. Graphql was basically an internal project for Facebook. Later on it moved under Graphql foundation which is owned by Linux foundation. Graphql provides a complete and understandable explanation of data in your API.

Graphql lets you ask for what you want in a single query, saving bandwidth and avoiding the avalanche of requests.

Grpahql has made its way to the forefront of API development nowadays. In this article , I would like to tell you some of the reasons why developers love to use Graphql and the major reasons for its quick acceptance.


Querying What You Need. Get Exactly The Same.

When you give a Graphql query to your API and you will get exactly what you asked . nothing more or nothing less. Graphql queries always return for seen results. This is why we say apps using Graphql are more fast and stable. They actually control the data not the server.


Develop Your API Without Versions

You can add new fields and types to your API’s without impacting the existing queries.

Many Resources In A Single Request.

Graphql enables what is known as declarative data fetching. in this method the user can specify exact data they need from API

For example , With REST an API endpoint may have existed in an application when there was a limited amount of data to be extracted. Over the years the endpoint could see an increase in the amount of data being returned, even for a limited number of records. Unfortunately , REST would not have provided a mechanism to limit which attributes of an entity should be returned.

Since REST frequently fetches too much data from an endpoint it can become difficult to ensure that the frontend is receiving the correct data set. With the Graphql on the other hand the exact data set is being declared , resulting in presenting the correct information without any doubt.


The Precedence Of Graphql

Declarative Data fetching.

Usually Graphql adopts declarative data fetching with its queries. This means Graphql decides which fields are needed for its UI, and it almost acts as UI driven data fetching. To retrieve all data in one request, a Graphql query that selects only the part of the data for the UI makes perfect sense. It offers a great separation of concerns: a client knows about the data requirements, the server knows about the data structure and how to resolve the data from the data source.


Graphql Not Only For React.

Graphql is not just exciting for React Developers. Even Though Facebook Showcased Graphql on a client side application with React, it is dissociated from any frontend or backend solution. The reference implementation of Graphql is written in JavaScript so the usage of Graphql in Angular, Cue, Express, Hapi, Koa and other JavaScript libraries on the client side and server side is possible.


Graphql Enclasp Present Day Trends.

Graphql embraces modern trends on how applications are built. You may only have one backend application, but multiple clients on the web, phones, and smartwatches depending on its data. Graphql can be used to connect the world at the same time it fulfills the requirements of each client application, nested relationships of data, fetching only the data without a dedicated API for each client.


Fastly Growing Graphql Ecosystem.

The Graphql ecosystem is growing. There are not only integrations for the strongly typed nature of Graphql for editors and IDEs, but also standalones for Graphql itself. As you all know ,Postman for REST APIs is now Graphql Playground for Graphql APIs. More than just technical aspects are evolving, there are conferences, meetups and communities forming for Graphql, as well as newsletters and podcasts.


Epilogue

To summarize, Graphql is meant to be used for client applications, where network bandwidth and latency are critical. It provided clients the ability to query an object graph. using Graphql clients also get the opportunity to choose what fields need to be included in the responses. This makes it a whole lot simpler and easier to use and manage data fetching on the client’s side.

I would say Graphql is not a replacement for REST, rather it compliments well with REST and can be used for specific use cases. And of course there are disadvantages we face while using Graphql.

Remember everything that comes up as new is not always rainbows and sunshine. There are always pros and there are always cones.

2 views0 comments

Recent Posts

See All