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
- by netflix blog-part1
- by netflix blog-part2
- by InfoQ video
Dont use graphql between db and server