100% Free Forever
AI-Powered Learning
Industry Expert Content
Certificates & Badges
Learn At Your Own Pace
Web

GraphQL

IntermediateProtocol7.6K learners

GraphQL is a query language and runtime for APIs that lets clients request exactly the data they need, in a single request, rather than relying on fixed endpoint responses.

#GraphQL#Web#Protocol#Intermediate#ApolloGraphQL#Hasura#React#GRPC#WebDevelopment#Glossary#SkillVeris

Definition

GraphQL is a query language and runtime for APIs that lets clients request exactly the data they need, in a single request, rather than relying on fixed endpoint responses.

Overview

GraphQL was created at Facebook (now Meta) to solve a problem common in REST APIs: clients often need to either over-fetch data they don't use or make several round trips to gather data spread across multiple endpoints. With GraphQL, a client sends a single query describing the exact shape of the data it wants, and the server returns a response matching that shape precisely. A GraphQL API is defined by a schema — a strongly typed description of every object, field, and operation available — which serves as both documentation and a validation contract between client and server. Clients can query nested, related data in one request (for example, a user and their recent posts and comments) instead of chaining multiple REST calls together. GraphQL is commonly implemented with servers like Apollo Server or platforms like Hasura that generate a GraphQL API automatically from a database schema, and it is frequently used alongside React frontends via client libraries such as Apollo Client. It is often discussed as an alternative to plain REST APIs and to gRPC, which optimizes for different goals like service-to-service performance; the API Design & Best Practices course covers when GraphQL is (and isn't) the right fit compared to these alternatives.

Specification

  • Client-specified queries that return exactly the requested fields
  • Strongly typed schema serving as both contract and documentation
  • Single request can fetch deeply nested, related data
  • Built-in introspection for exploring an API's capabilities
  • Subscriptions for real-time, event-driven data updates
  • Mutations for structured, typed write operations
  • Broad ecosystem of servers, clients, and tooling across languages

Use Cases

Building APIs that serve varied clients with different data needs
Reducing over-fetching and under-fetching common in REST APIs
Aggregating data from multiple backend services into one API
Real-time features using GraphQL subscriptions
Auto-generating APIs directly from a database schema
Mobile app backends where minimizing network requests matters

History

GraphQL is a query language for APIs that Facebook (now Meta) began developing internally in 2012 to power its mobile applications, releasing a draft specification and reference implementation as open source in 2015. Instead of multiple fixed REST endpoints, GraphQL exposes a single endpoint against a typed schema, letting clients request exactly the fields they need in one round trip. In 2018 stewardship moved to the newly formed GraphQL Foundation, hosted by the non-profit Linux Foundation, to provide a neutral home for the specification and its ecosystem, with founding members including Airbnb, GitHub, Shopify, and Twitter. It has since become one of the most widely adopted alternatives to REST for API design.

Frequently Asked Questions