Oct 7, 2022
GraphQL + REST API
Let's understand how we can combine the best of Graph QL with REST API to achieve the maximum results.
Author


Book a call
Table of Contents
Pre-requisite
- GraphQL
- React
Before Diving into the topic, let's understand what is GraphQL first.
What is GraphQL?
GraphQL is a query language for your API and a server-side runtime for executing queries using a type system you define for your data. GraphQL isn't tied to any specific database or storage engine and is instead backed by your existing code and data.
Why Use GraphQL over a Traditional REST API?
- One Endpoint
- Declarative Response
- Fewer Server Requests
- Auto Documentation of Queries
The mantra of GraphQL is - “Ask for what you want − and get it”.
GraphQL With REST
Now, let's see how we can use the existing REST APIs as GraphQL Query.
How To Use REST API in GraphQL?
- Apollo Client
- URQL
- Relay
But for using REST API with GraphQL, Apollo client is the only package to support REST as of now.
How to Implement REST API in Apollo Client?
First, let's create a new React app.
Simple, right?!
Creating an App
We need to write a GraphQL query to get all the data.
Just two changes from the traditional query.
- @rest - it's added to denote a REST API
- path - to mention the path of the API.
2. Executing the GET ALL query and displaying the data.
3. Adding new todo data using the query.
To pass the values to the body of the API call, we can pass them inside the `addTodo` function as variables parameter. Inside variables, we can pass the data as part of the `input (bodyKey input in the query)` object.
5. Delete a Todo by id.
6. Executing the Delete todo in the code.
Instead of Converting the existing REST APIs into a GraphQL API, you can now directly integrate REST APIs with GraphQL queries.
Subscribe to Our Newsletter
Subscribe to RSS
Press & Media Hub RSS FeedRelated Articles.
More from the engineering frontline.
Dive deep into our research and insights on design, development, and the impact of various trends to businesses.

Jun 27, 2026
Building a Resilient Hybrid-Cloud Network with WireGuard HA, Route-Based Failover, and Deep Observability

Jun 26, 2026
GeekyAnts Wins AI and Digital Transformation Excellence Award at ET Now Business Conclave 2026

Jun 25, 2026