GraphQL (microservices) architecture by Apollo

RayRay
ITNEXT
Published in
7 min readJan 15, 2020

--

Why use GraphQL and not REST

If you look from the perspective of the client (the frontend) there are a few challenges with REST API’s when getting the data.

Challenges with REST

For years we are using REST API’s because they were more convenient than getting the data from the server and render it simultaneously with the HTML which caused in continuously reloading the page of your application.

But with all the pros of REST, there is also a couple of cons.

  1. Doing a REST call gives the client more data than needed, so more data is needed to be downloaded
  2. The data structure of a REST endpoint is not predictable in the frontend application
  3. Calling multiple endpoints to merge data before showing screens to the user

GraphQL to the rescue

GraphQL is a query language for your API, and a server-side runtime for executing queries by using a type system you define for your data

In the time we heavily rely on REST API’s we learned a lot of things that could be better.

With GraphQL we describe in the client which data we want to have instead of just asking all the data.

--

--

I’m a 🇳🇱 lead frontend developer who writes about WebDev | JavaScript | TypeScript | Vuejs | Web Components | Design Systems | NuxtJS | StencilJS | CSS