Examples¶
Every configuration on these pages is a real file of the repository, under
examples/. make test-config compiles each
one with its schema, renders it and runs openresty -t on the result, so the examples cannot drift
from the code.
| Example | Shows | Files |
|---|---|---|
| Full server | default mode: gqlgw brings its own server {}, memcached, metrics, purge |
examples/full/ |
| Locations only | gqlgw inside an existing server {} (its TLS, its domain) |
examples/locations-only/ |
| Batch vs no batch | N+1, deduplication, @batch, @batch + @cache |
bench/schema.graphqls |
| Auth context forwarding | header allowlist and denylist, service keys, PRIVATE cache, sources.d |
examples/auth/ |
| Mutations | POST/PATCH with JSON bodies, serial execution |
examples/docker/ |
| Unions and interfaces | @discriminator, runtime types |
examples/docker/ |
The Docker example (examples/docker/) is the one of Getting started.
It also serves as the integration test of the image (make docker-test).
Most examples use the blog schema of examples/docker/schema.graphqls: two REST services,
users and posts.
flowchart LR
Q[Query] -- "user(id)" --> users[(users)]
Q -- "posts(limit, tag)" --> posts[(posts)]
Q -- "search(q)" --> posts
P[Post] -- "author (batched)" --> users
U[User] -- posts --> posts
M[Mutation] -- "renameUser: PATCH" --> users
M -- "createPost: POST" --> posts