---
title: "Discussion on \"GraphQL vs REST\" | Hashnode"
description: "Discussion on \"GraphQL vs REST\". Learning curve, tooling, and development in GraphQL vs REST"
url: "https://hashnode.com/posts/graphql-vs-rest/62e8facf3f084d032011cfea"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [GraphQL vs REST](https://akoskm.com/graphql-vs-rest?utm_source=hashnode&utm_medium=feed)

Learning curve, tooling, and development in GraphQL vs REST

Aug 2, 2022 · 6 min read · akoskm.com  
Read the article

-   [#web-development](https://hashnode.com/tag/web-development)
-   [#javascript](https://hashnode.com/tag/javascript)
-   [#graphql](https://hashnode.com/tag/graphql)
-   [#2articles1week](https://hashnode.com/tag/2articles1week)
-   [#beginners](https://hashnode.com/tag/beginners)

## Written by

[Ákos Kőműves](https://hashnode.com/@akoskm)

@akoskm

  
[View profile](https://hashnode.com/@akoskm)

Full-Stack Developer and Writer

I build web apps and make educational content to help web developers.

## Responses 2

Markdown supported · ⌘↵ to post

[Subham Sahu](https://hashnode.com/@subhamx)

[Aug 4, 2022](https://hashnode.com/posts/graphql-vs-rest/62e8facf3f084d032011cfea/comment/62ebb8b0cbce7c268014d3de)

Thank you for this nice article. I would like to add a few more things:

1.  In graphQL, we have an introspection query, which is really handy during development. (Don't forget to disable it in prod 🥲).
2.  One of the lesser talked things about graphQL is data modelling. For Apollo cache to work efficiently, we must ensure that the data modelling is done nicely. If you ensure that you're not using any antipattern then usually it's safe. I've faced this issue earlier. (maybe I should document it? 🤔)
3.  REST is faster: GraphQL does type checking, and all and thus they're slower than REST. But it makes the system less prone to errors. (There're tradeoffs to be made).
4.  Problem of N+1 queries: We might need to use the dataloader pattern to solve the N+1 issue, which is an additonal implementation overhead. Even after using dataloader pattern the number of queries needed to resolve one request will be greater than one simple query we need to write in REST. But do note that, the number of customized endpoints are less in graphQL, and we've granular control over data fetching, which are few pros.

[Ákos Kőműves](https://hashnode.com/@akoskm)

[Aug 4, 2022](https://hashnode.com/posts/graphql-vs-rest/62e8facf3f084d032011cfea/comment/62ebb8b0cbce7c268014d3de#reply-62ebb9f1cbce7c268014d413)

Very good points Subham, a few thoughts:

3) I always do some kind of validation on my REST endpoints as well - mostly with AJV. I haven't measured which one is faster but in my case, both REST and GraphQL have the overhead of validation - but I don't think that's a bad thing.

4) I actually avoided the N+1 queries with GraphQL, this was one of the reasons why I started using it. ie before I used to fetch multiple projects and recent history for each project on a dashboard - now the entire thing comes through a single query.

Thank you for your insights! 🙌

[Subham Sahu](https://hashnode.com/@subhamx)

[Aug 4, 2022](https://hashnode.com/posts/graphql-vs-rest/62e8facf3f084d032011cfea/comment/62ebb8b0cbce7c268014d3de#reply-62ebc168f583cc2636e52fcf)

[Ákos Kőműves](https://hashnode.com/@akoskm) ; Thank you for the follow-up.

> always do some kind of validation on my REST endpoints as well - mostly with AJV.

True. But please note that the graphQL validation is limited to only type checking. Say there is a `mutation` where you need a **specific field to always be an integer greater than 5**. **This additional validation needs to be implemented inside the resolver.** In the case of REST, you could've used libraries like [yup](https://www.npmjs.com/package/yup) for both type checking and additional validation.

> I actually avoided the N+1 queries with GraphQL, this was one of the reasons why I started using it

You got me wrong. You're mentioning that **"graphQL helps us in ensuring that data fetching is exact (neither over fetched nor under etched), and we can do it in a single query from client"**.

I was talking about the number of database queries in resolvers. Say we have a `Countries` and `Cities` table. Clearly, there's a one-to-many relation.

> Assuming there're `x` countries and everyone has `c1`, `c2`... `cX` cities respectively.

If I ask for all countries and their cities, then without using the data loader pattern, the following will happen in graphQL:

1.  fetch the countries.
2.  for every country's city, fetch the details.

Total number of database queries: `1 (to fetch countries) + c1 + c2 ... cX`

With data loader, it will be: `1 + x` database queries

If you provide a single endpoint (like in REST), the number of DB access will be just `1`. (using joins).

---

By the way, please note that I equally adore GraphQL. (Although my arguments might sound overwise 🥺). Maintaining software is a big challenge, and this is where GraphQL shines.

[Ákos Kőműves](https://hashnode.com/@akoskm)

[Aug 4, 2022](https://hashnode.com/posts/graphql-vs-rest/62e8facf3f084d032011cfea/comment/62ebb8b0cbce7c268014d3de#reply-62ebc463f583cc2636e5305f)

Got you [Subham Sahu](https://hashnode.com/@subhamx) for the number of queries - I thought you were talking about the number of GraphQL queries.

GraphQL isn't perfect either but for what it meant to fix - mostly to fetch the correct payload for tons of different devices without having to implement different API endpoints or conventions (like JSON:API) and without causing too much overload for backend developers.

[Elijah Trillionz](https://hashnode.com/@elijahtrillionz)

[Aug 2, 2022](https://hashnode.com/posts/graphql-vs-rest/62e8facf3f084d032011cfea/comment/62e8fd713f084d032011d12f)

Really nice writeup.

It's really cool that the client can control the payload to be received because over-fetching has always been a burden for me in REST.

Thanks for sharing, Akos

[Ákos Kőműves](https://hashnode.com/@akoskm)

[Aug 2, 2022](https://hashnode.com/posts/graphql-vs-rest/62e8facf3f084d032011cfea/comment/62e8fd713f084d032011d12f#reply-62e8fde13f084d032011d217)

Thanks! Glad you liked it, Elijah! 🙌
