Kavin Thanesjesdapong
3 min readMay 27, 2021

--

Why GraphQL is simply “built different”.

In FullStack Academy’s curriculum, students were taught RESTful APIs. Although, RESTful APIs comes with some pretty sweet advantages such as being easy to implement and flexible, it also comes with some disadvantages. In RESTful APIs there are multiple endpoints for the client server communication and data is usually sent to these different paths which the server than parses to retrieve information that the user wants. Supposed you wanted to retrieve information about a user and we only want this user’s first name and last name. In a RESTful API you will have to target the specific resource, which then will retrieve all information about the user with all the fields that relate. Of course, you could use query parameters to limit what is retrieved from said paths but that adds more complexity to the API and often you will still end up retrieving more than you originally had intended. For example:

Information that is retrieved by using a HTTP/URL combo with Dynamic inputs to find information about a specific user.

As illustrated with the image above this is most likely the information that will be returned as a result of our GET request. See how this can easily become a problem?

This is where GraphQL comes in. GraphQL stands for Graph Query Language and it is an open-source data query and manipulation language for APIs. This querying language was developed by Facebook back in 2012 and was only released internally up until 2015 when it was publicly released. So, with that introduction of GraphQL let’s discuss how you would query for the same information in the scenario mentioned up above.

Querying for the same Data

Notice how when we’re querying for information about the same exact user, GraphQL allows us to specify exactly what information we want extracted as a result of our query. This is the advantage that GraphQL has over RESTful API’s it allows developers to query for exactly what they need and nothing more. When specifying the information that you would like retrieved you’re also reducing the amount of data being transferred and this just adds on to the list of advantages that comes from learning GraphQL.

This has been a high level overview of GraphQL and its advantageous. I highly suggest taking a deeper dive into it as it could prove to be extremely helpful in your upcoming projects. I’m by no means an expert on GraphQL but if have any questions in regards to GraphQL feel free to reach me here!

--

--