GraphQL
It is a data query and manipulation language that allows specifying what data is to be retrieved or modified. This is a control/signalling plane technology developed by Facebook in 2012 and open sourced in 2015, and is now maintained by the GraphQL foundation, hosted by the non-profit Linux foundation.
GraphQL is a query language for APIs that lets clients request exactly the data they need. Unlike REST, it avoids over-fetching/under-fetching and exposes a single endpoint.
Core concepts:
- Operations - Query, Mutation, Subscription
- Schemas - Define types, queries, mutations, and relationships. Acts as contract between server and client
- Resolvers - Functions for fetching data for a field
- Introspection - Ability to query the schema itself via
__schema
and__type
- Fragments
- Error handling
- Variables
- Directives
Implementation concepts:
- Authentication
- Batching and Batching utilities(DataLoader)
- Federation(see Apollo Federation)
- Subscriptions usage(WebSockets)
- Query complexity limits using
cost
- Union vs Interface
- Caching
- Persisted Queries
- Securing
- File Uploads(see Apollo Upload Server)
Operations
- Query for reading
- Mutation for modifying(create, delete, update)
- Subscription for real time updates