GraphQL – hot trend or new standard?

REST has always been the leading architecture for APIs. For many years the industry couldn’t propose a noteworthy architectural pattern that could be used as an alternative for RESTful APIs.

It has changed in 2015 when GraphQL been publicly released.

What’s a GraphQL

GraphQL is an open-source data query & manipulation language for APIs. GraphQL was developed by Facebook internally until it was open-sourced in 2015. Since then, GraphQL’s popularity is growing rapidly, which led to its adoption by such companies as Netflix, Airbnb or PayPal. Why so? What exactly GraphQL is and how it differs from REST?

GraphQL vs REST

In GraphQL Docummnetary video Lee Byron, one of GraphQL’s creators, compared REST API to a traditional vending machine where to get one item you need to press one button. If you want to get more items you need to get the one-by-one, pressing lots of buttons, repeating the process many times for different items you want to get from the vending machine. This takes time…

Now imagine a vending machine with special buttons allowing you to get multiple things at once. All you need to do is press a special button and you get all the items you want from a vending machine. This kind of super vending machine is exactly what GraphQL does in terms of retrieving data from the API.

In GraphQL we have a single endpoint being able to process complex queries, providing data according to requirements sent by the client (mobile or web app). You query the GraphQL server for specific data and it will respond with exact data that was requested. As opposed to REST where you need to call multiple endpoints to get the exact mix of data you need, which results in more bits being transferred over the wire.

GraphQL vs REST - vending machine example

GraphQL Structure

GraphQL is all about asking for specific fields on objects. To do it we first need to get common with the basic GraphQL components:

 

1. GraphQL schema is a core element of any GraphQL implementation. Schema is your source of truth, it defines the functionalities available for the clients connected to a GraphQL API.

2. Object Type is a basic component of a GraphQL schema.

3. A query is a basic operation used to fetch values. It has a form of a string that a GraphQL server can parse & respond to with data specified in a query.

4. Resolver is a piece of code telling the GraphQL server what to do with the queries like how to fetch the data corresponding to a specific field defined in a GraphQL schema.

 

 

Image representing the GraphQL structure

Source:  graphdatamodeling.com 

GraphQL Editor – a way to start with GraphQL

The GraphQL Editor is a supportive tool for both advanced GraphQL users as well as those taking their first steps with GraphQL APIs. The main idea behind it was to create an environment for GraphQL gathering many useful micro-features that facilitates such elements as learning new technology, development, managing project or easing the process of onboarding new team members into a project.

One of the editor’s key features is its ability to provide a visual interface (fully editable) for a GQL schema. The tool provides many useful features that will help you:

1. Lower entry barrier for GraphQL

2. Speed up GraphQL development

3. Make sure that your GraphQL API is well-developed (GraphQL-Zeus)

4. Fix communication between developers & business people in your team

 

 

Users who are new to GraphQL will appreciate the built-in interactive tutorial. During six short tasks, they will be briefed on the basis of SDL syntax like GraphQL Types, Queries, Mutations, Inputs, etc. This will make it a lot easier to start working on their first GraphQL schema. Click the button below and you will be redirected to the GraphQL Interactive tutorialButton starting an interactive GraphQL tutorial

Conclusion

GraphQL was built to solve a very narrow problem. After its public release, its popularity skyrocketed!  Over the past years, many development teams adopted GraphQL technology which earned it a tittle of a new industry standard.  More and more teams are adopting GraphQL because it saves them a lot of time. The main GraphQL quality is that it allows the client to fetch just what you need, which makes it wins over REST on slow networks which is still an issue. All the above gives me the confidence to believe that GraphQL is not just a hot new trend, but the future of APIs. What do you think?

SHARE ON
GraphQL – hot trend or new standard?

You May Also Like

Leave a Reply

Your email address will not be published.