What is GraphQL

Published: (March 15, 2026 at 07:20 AM EDT)
3 min read
Source: Dev.to

Source: Dev.to

Overview

  • Developed by Facebook
  • A query language for APIs
  • User‑friendly because the data format of API requests and responses are similar
  • REST is an architecture (design), while GraphQL is a language (DSL)

REST Example

Send requests to endpoints using HTTP verbs:

curl https://api.bmf-tech.com/v1/configs
[
  {
    "id": 1,
    "name": "title",
    "alias_name": "Title",
    "value": "bmf-tech",
    "created_at": "2017-09-25 23:08:23",
    "deleted_at": null
  }
]

GraphQL Example

Send queries to a single endpoint:

curl https://api.bmf-tech.com/api
{
  configs {
    id
    name
    alias_name
    value
    created_at
    updated_at
    deleted_at
  }
}
[
  {
    "id": 1,
    "name": "title",
    "alias_name": "Title",
    "value": "bmf-tech",
    "created_at": "2017-09-25 23:08:23",
    "deleted_at": null
  }
]

Comparison Summary

FeatureRESTGraphQL
EndpointsMultipleSingle
HTTP VerbsDependentIndependent
Type SystemNoneAvailable
Versioning RequiredYesNo
Documentation RequiredYesNo (API definition serves as docs)
Resource LimitationMainly call countHandled according to resource amount
Response FlexibilityFixed response per endpointClient specifies desired fields
PerformanceMay need multiple requestsFewer requests, larger payloads
MonitoringPer‑endpoint monitoring possibleRequires custom measures for queries
CachingCan use HTTP cacheCannot rely on HTTP cache

Practical Considerations

  • Load Calculation: With GraphQL you often need methods for load calculation (e.g., based on the number of objects returned).
  • Documentation: GraphQL’s schema acts as a self‑documenting API; explicit external docs are less critical.
  • Libraries: Implementations typically require libraries for parsing queries.
  • Performance: Not inherently faster than REST; benefits come from reduced round‑trips.
  • Data Volume: Both approaches need pagination or field selection to control payload size.
  • Monitoring: Since GraphQL uses a single endpoint, additional tooling may be needed to track query‑level performance.
  • Caching: Standard HTTP caching is not applicable; alternative caching strategies should be explored.

When to Consider GraphQL

  • Applications with many components and complex UIs where the number of requests becomes a bottleneck.
  • Situations where clients need to fetch varied data shapes without multiple round‑trips.

Resources

  • graphql.org – Official GraphQL documentation
  • facebook/graphql RFCs – Specification and proposals
  • “A small rebuttal to What is GraphQL suitable for” – Discussion on use‑cases
  • “Memo when implementing GraphQL API in a Rails app” – Practical implementation notes
  • “Explaining GraphQL from a beginner’s perspective” – Introductory guide comparing REST and GraphQL
0 views
Back to Blog

Related posts

Read more »

The 49MB web page

Article URL: https://thatshubham.com/blog/news-audit Comments URL: https://news.ycombinator.com/item?id=47390945 Points: 203 Comments: 126...

The 49MB Web Page

Article URL: https://thatshubham.com/blog/news-audit Comments URL: https://news.ycombinator.com/item?id=47390945 Points: 8 Comments: 0...