Benefits of Using GraphQL

Sude Kılıç
Nov 30, 2020 · 3 min read

Welcome to my first post, I hope you enjoy reading!

Image for post
Image for post

Are you building an API? Have you ever wasted your time and energy to decide how to structure URLs? If your answer is yes, I would like to share my experiences and opinions about GraphQL, which is seen as the next big thing in API architecture.

GraphQL is basically a query language which provides a query in the form of a string that is sent to a server. The server interprets the query and then returns the result in JSON format to the client.

In the following you can see the factors that make GraphQL so powerful and the advantages I have experienced when using it at Koçfinans.

No Over-Fetching or Under-Fetching

One of the key advantages of GraphQL has over REST is, GraphQL’s ability to fetch only what is required. Developer defines the exact fields that they want to fetch and it fetches the data of only these fields.

Strongly-typed Schema Definition

All the types (Boolean, String, Int, Float, ID, Scalar) supported by the APIs are specified in the schema in GraphQL Schema Definition Language (SDL).

Image for post
Image for post

Validations can be added by specifying the mandatory status of the fields.

Image for post
Image for post
totalPrice: mandatory ~ promotionAmount: non-mandatory

Good Choice for Microservices

Multiple systems can be integrated behind GraphQL API. It unifies them, conceals their complexity and helps to manage communication between multiple services by combining them into one GraphQL schema.

Speed of Development

GraphQL is much faster than other communication APIs, because it allows developer to select only the specific fields which they want to query.

Image for post
Image for post

It is no longer necessary to specify data requirements on the server side such as which fields need to be fetched and exposed.

As the official website of GraphQL puts it,

"Describe your data, ask for what you want, get predictable results."

Code Sharing

Higher component level can be used for repetitive fields in different queries to increase reusability. This feature is referred as fragments and it allows to get different data while retaining the same schema field.

Image for post
Image for post

Explore With Postman

Even though Postman is mostly known as an advanced REST client, it is a more comprehensive tool that handles any calls sent over HTTP.

Image for post
Image for post

As the official website of Postman describes it,

"Postman provides a separate interface to author GraphQL variables. After defining your GraphQL query in the Query editor, you can author and edit GraphQL variables in the adjacent variables editor."

This is the end of my first post and I really hope you have enjoyed reading it. Rather than providing technical information about GraphQL, I wanted to talk about what kind of benefits and easiness I experienced while using it. I hope our paths cross in many more posts. Happy developments!

Koçfinans Tech

Koçfinans teknoloji ekibi olarak, gündelik hayatta…

Sude Kılıç

Written by

Fullstack Developer @Kocfinans

Koçfinans Tech

Koçfinans teknoloji ekibi olarak, gündelik hayatta karşılaştığımız sorunları ve ürettiğimiz çözümleri paylaşıyoruz. Keyifli okumalar …

Sude Kılıç

Written by

Fullstack Developer @Kocfinans

Koçfinans Tech

Koçfinans teknoloji ekibi olarak, gündelik hayatta karşılaştığımız sorunları ve ürettiğimiz çözümleri paylaşıyoruz. Keyifli okumalar …

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic. Write on Medium

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store