andersch.dev

<2025-03-26 Wed>
[ web ]

GraphQL

GraphQL is a query language for APIs and a runtime for executing those queries with your existing data.

Tools for implementing GraphQL include GraphQL.js, Apollo and Relay.

Features:

Use Cases:

Basic Example

Query:

{
  user(id: "1") {
    name
    email
    posts(limit: 2) {
      title
      content
    }
  }
}

Response:

{
  "data": {
    "user": {
      "name": "John Doe",
      "email": "john@example.com",
      "posts": [
        {
          "title": "GraphQL Basics",
          "content": "This is a post about GraphQL."
        },
        {
          "title": "Advanced GraphQL",
          "content": "This is a post about advanced GraphQL topics."
        }
      ]
    }
  }
}