Glossary

GraphQL

TL;DR

GraphQL is a query language and runtime for APIs that allows clients to request specific data they need, reducing over-fetching and under-fetching issues common with REST APIs.


Concept

GraphQL is an open-source query language and runtime for APIs developed by Facebook. Unlike REST, which exposes multiple endpoints with fixed data structures, GraphQL provides a single endpoint where clients can specify exactly what data they need.

Key features and concepts of GraphQL include:

  1. Schema Definition: A strongly-typed schema that defines the capabilities of the API, including types, fields, and relationships.

  2. Queries: Client requests that specify exactly which fields and nested objects to retrieve, enabling precise data fetching.

  3. Mutations: Operations that modify server-side data, equivalent to POST, PUT, and DELETE in REST.

  4. Subscriptions: Real-time data streaming capabilities that allow clients to receive updates when specific events occur.

  5. Introspection: Built-in ability to query the schema itself, enabling powerful development tools and documentation.

GraphQL addresses common issues with REST APIs such as:

  • Over-fetching: Retrieving more data than needed
  • Under-fetching: Not getting enough data in a single request, requiring multiple API calls
  • Versioning: Constantly evolving APIs with backward compatibility

Organizations adopt GraphQL to improve mobile application performance, reduce network usage, enable faster frontend development, and provide more flexible APIs for diverse client requirements. It’s particularly valuable in complex applications with multiple data sources and varying client needs.

Related words: REST API Gateway DNS