GraphQL

Query The Right Way!

Vincent Collis
3 min readJul 9, 2021

So what is GraphQL?

GraphQL is a query language for APIs and a runtime for fulfilling those queries with your existing data. GraphQL provides a complete and understandable description of the data in your API, gives clients the power to ask for exactly what they need and nothing more, makes it easier to evolve APIs over time, and enables powerful developer tools.

Originally developed in 2012 at Facebook as a better data-fetching solution for underpowered mobile devices, GraphQL was open-sourced in 2015. In 2018, it was moved under the care of the Linux Foundation, which maintains other important projects like Node.js, Kubernetes, and, of course, Linux itself.

Now, in recent years, REST has become the dominant API style for building backend web services. With REST, you could signal the type of request we want to make (ex: GET, POST, PUT, or DELETE) and the resource we’d like to fetch or interact with (ex: /api/pets/1) using an HTTP method and a URL.

It’s a great approach but REST comes with some downsides like:

  • Over-fetching
  • Multiple requests for multiple resources
  • Waterfall network requests on nested data
  • Each client need to know the location of each service

But here comes Graph QL to the rescue!

As an API technology designed for flexibility, GraphQL is a strong enabler for both developers and consumers of APIs, as well as the organizations behind them. Here are some key ways where GraphQL shines.

One Data Graph for All

GraphQL is an excellent choice for organizations with multiple teams and systems that want to make their data easily available through one unified API.

No matter how many databases, services, legacy systems, and third-party APIs you use, GraphQL can hide this complexity by providing a single endpoint that clients can talk to. The GraphQL server is responsible for fetching data from the right places, and clients never need to know the details of where different pieces of data are coming from. As a result, the GraphQL ecosystem provides maximum flexibility when it comes to making data easily available for customers and internal users.

No Over-Fetching or Under-Fetching

Another huge benefit for GraphQL API clients is that they can request exactly what data they need, even across related entities. This is especially important because different clients have different data requirements, either because of different business logic or because they are simply presenting a different view of data (e.g., web vs. mobile) and may also have different hardware limitations. GraphQL solves this issue by serving exactly the data which each client requests, nothing more and nothing less.

Better Developer Experience

The GraphQL ecosystem comes with a number of tools that make working with GraphQL a breeze. Tools such as GraphiQL and GraphQL Playground provide a rich experience, allowing developers to inspect and try out APIs with minimal effort, thanks to the self-documenting features which we will get to in the next section!

--

--