The GraphQL gateway for the @imqueue Car-Wash tutorial.
It is the single public entry point in front of the backend fleet (user, auth, car,
time-table): it exposes one Relay-style GraphQL schema and orchestrates the typed
@imqueue/rpc services behind it, resolving each GraphQL field to one or more RPC calls. The
React front-end web-app talks to this gateway.
Its REST counterpart, api-rest, fronts the very
same fleet over OpenAPI — the two gateways are the whole point of the tutorial.
This repo is one piece of the imqueue-sandbox tutorial — a complete car-wash booking app built from independent RPC microservices that communicate over a Redis-backed message queue.
| Repo | Role | Store |
|---|---|---|
| user | Customer accounts & their garage | MongoDB |
| auth | Login, JWT issuing & revocation | Redis |
| car | Car catalog (makes / models / types) | in-memory |
| time-table | Washing reservations & schedule | PostgreSQL |
| api | GraphQL gateway orchestrating the fleet | — |
| api-rest | REST/OpenAPI gateway over the same fleet | — |
| web-app | React front-end on api (GraphQL/Relay) |
— |
| web-app-rest | React front-end on api-rest (REST) |
— |
- Built on express 5 + graphql-yoga. On start it boots the four generated RPC clients
(
src/clients/) into a shared context and mounts the GraphQL endpoint at/. - Relay conventions: global IDs (
graphql-relay), anodeinterface, connection-based pagination forusers, andmutationWithClientMutationIdfor every mutation. - Field projection:
graphql-fields-listturns the client's selection set into the minimalfieldsargument for each RPC call, so services only compute what was asked for. - Authorization: field-level validators enforce owner/admin rules; non-admin
userslistings are capped at 100 records.
Queries — node, user, users, car, cars, brands, options, reservation,
reservations.
Mutations — login, logout, updateUser (create/update), addCar, removeCar,
reserve, cancelReservation.
The printed SDL is committed at src/schema.graphql.
Clients send the JWT issued by the login mutation in the X-Auth-User header. The gateway
resolves it to the current user via the auth service (auth.verify) for every request.
Environment variables (loaded from an optional .env via process.loadEnvFile()):
| Variable | Default | Purpose |
|---|---|---|
API_PORT |
8888 |
HTTP port (auto-increments if busy). |
IMQ_REDIS |
localhost:6379 |
Redis endpoint(s) for the RPC message queue. |
NODE_ENV |
development |
Enables the GraphiQL IDE at / in development. |
API_SSL_KEY / API_SSL_CERT |
— | TLS key/cert paths; used only with the --SECURED flag. |
Development mode (rebuilds and restarts on change; GraphiQL enabled):
npm run devProduction mode:
npm start- GraphQL endpoint:
http://localhost:8888/ - GraphiQL IDE (development only):
http://localhost:8888/
Requires the backend fleet running and reachable over IMQ_REDIS.
npm run rebuild-clients— regenerate the four RPC clients insrc/clients/from the live services using theimqCLI.npm run update-schema— build and re-print the GraphQL SDL tosrc/schema.graphql.