How GraphQL Works

TL;DR
GraphQL is built on a strong type system. Clients describe the data they want, and the server responds with that data - nothing more, nothing less.

The Building Blocks

ComponentDescriptionExample
SchemaThe blueprint of your data - types, fields, and relationshipstype User { id: ID! name: String! }
QueryHow clients request data{ user(id: "1") { name } }
MutationFor creating, updating, or deleting datamutation { updateUser(id: "1", name: "New Name") { id } }
SubscriptionFor real-time updatessubscription { newMessage { text } }

Request-Response Flow

Ecosystem Growth

  1. Client sends a query to the GraphQL endpoint.
  2. Server validates the query against the schema.
  3. Resolvers fetch and shape the requested data.
  4. Response is returned in JSON.

Example Mutation

GraphQL Query
Response