Welcome to my first post, I hope you enjoy reading!
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).
Validations can be added by specifying the mandatory status of the fields.
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.
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."
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.
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.
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!