Difference Between REST And GraphQL API

1. Method to perform data operations

With RESTful APIs, you have different HTTP methods to perform CRUD operations.

Whereas with GraphQL, you use queries and mutations to perform data operations.

2. Overfetching and under fetching

With REST API, you either often fetch an unnecessary amount of data or fetch data in multiple API calls.

With GraphQL, you only get the data that you have requested.

3. Endpoints

REST API leads to fetching different data from multiple endpoints.

GraphQL provides a single endpoint from where you can read and manipulate data.

4. Cache

REST API leverages the caching feature. The different operations, like the GET, POST, etc., can be cached and stay in the browser history.

GraphQL doesn't follow the HTTP specs and uses a single endpoint. It is up to developers to ensure that caching is implemented.

5. Language

REST API is an API type that lets you perform CRUD operations between client and server.

GraphQL is a query language that allows you to read and mutate the data in APIs.