Inhaltsverzeichnis
3.1 GraphQL Basics
GraphQL1) enables flexible, precise data queries.
What is GraphQL?
GraphQL2) is a query language for APIs and a runtime for executing these queries. Unlike REST3), clients can request exactly the data they need.
Endpoint
POST /api/v1/dsn/{dbName}/graphql
Content-Type: application/json
Simple Query
{ "query": "{ customers { id name country } }" }
With Parameters
{ "query": "{ customers(first: 10, filter: \"Country eq 'DE'\") { id name } }" }
Retrieve Schema
GET /api/v1/dsn/demo/graphql/schema
Returns the GraphQL schema in SDL4) format.
Advantages Over REST
| Aspect | REST | GraphQL |
|---|---|---|
| Endpoints | Many (per resource) | One |
| Over-fetching | Common | Never |
| Under-fetching | Common (N+1) | Never |
| Type safety | Optional | Built-in |
| Documentation | External (OpenAPI5)) | Integrated (Introspection) |
Sources
1)
GraphQL Specification: https://spec.graphql.org/
2)
GraphQL Foundation: https://graphql.org/
3)
Representational State Transfer: https://en.wikipedia.org/wiki/Representational_state_transfer
4)
Schema Definition Language: https://graphql.org/learn/schema/
5)
OpenAPI Specification: https://www.openapis.org/
Zuletzt geändert: on 2026/01/29 at 11:30 PM