Skip to content

Instantly share code, notes, and snippets.

@K3ndev
Last active February 19, 2024 12:47
Show Gist options
  • Save K3ndev/49a86869c8a085a01099564b3e338e6b to your computer and use it in GitHub Desktop.
Save K3ndev/49a86869c8a085a01099564b3e338e6b to your computer and use it in GitHub Desktop.
why-graphQL

Reason 1: Over-fetching

  • Over-fetching occurs when a client retrieves more data than is actually needed for a particular task or view, resulting in wasted bandwidth and slower performance
  • Traditional RESTful APIs often suffer from over-fetching due to the fixed data structure returned by each endpoint, which may include unnecessary fields.
  • GraphQL addresses this issue by allowing clients to specify their data requirements upfront in a single query, reducing the likelihood of over-fetching by retrieving only the required data fields.

Reason 2: Under-fetching

  • In contrast to over-fetching, under-fetching occurs when a client needs to make multiple requests to different endpoints to gather the necessary data for a single view.
  • GraphQL addresses this issue by enabling clients to specify their data requirements upfront in a single query, thereby reducing the number of round trips to the server.

Reason 3: Auto Documentation

  • GraphQL APIs come with built-in documentation, generated automatically from the GraphQL schema. This feature enhances developer experience and accelerates API understanding and adoption.

Reason 4: Auto Completion

  • GraphQL offers auto-completion, which assists developers in writing correct and efficient queries. This feature streamlines the development process, leading to faster iteration and fewer debugging cycles.

Using graphQL federation in microservice

Dont use graphql between db and server

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment