The FTGO GraphQL API Gateway is a Node.js/TypeScript server that provides a unified GraphQL endpoint over the FTGO application’s backend microservices. Unlike the REST API gateway — which exposes individual service endpoints directly — the GraphQL gateway performs API composition at the server, allowing clients to retrieve deeply nested data (for example, an order with its consumer and restaurant details) in a single request.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/microservices-patterns/ftgo-application/llms.txt
Use this file to discover all available pages before exploring further.
How it works
The gateway accepts GraphQL queries and mutations at/graphql and resolves them by calling the appropriate backend REST services. Each service is wrapped in a proxy class that handles HTTP communication:
OrderServiceProxy— calls the Order History Service to fetch orders by consumer ID or by order ID.ConsumerServiceProxy— calls the Consumer Service to look up consumers and create new ones. Uses DataLoader to batch multiple consumer lookups within a single request cycle.RestaurantServiceProxy— calls the Restaurant Service to look up restaurant details. Also uses DataLoader for batching.
graphql-tools and served through Apollo Server on Express.
Architecture
Queries and mutations
| Operation | Type | Description |
|---|---|---|
orders(consumerId) | Query | Returns all orders placed by a consumer |
order(orderId) | Query | Returns a single order by ID |
consumer(consumerId) | Query | Returns a consumer and optionally their orders |
createConsumer(c) | Mutation | Creates a new consumer and returns the created record |
Order field resolver automatically fetches related Consumer, Restaurant, and DeliveryInfo objects when the client requests them, so there is no over-fetching.
Running the gateway
With Docker Compose
The gateway is included indocker-compose-api-gateway-graphql.yml. Start it alongside the dependent services:
Environment variables
| Variable | Default | Description |
|---|---|---|
ORDER_HISTORY_SERVICE_URL | http://localhost:8080 | Base URL for the Order History Service |
CONSUMER_SERVICE_URL | http://localhost:8080 | Base URL for the Consumer Service |
RESTAURANT_SERVICE_URL | http://localhost:8080 | Base URL for the Restaurant Service |
Building and running locally
Example query
The following query fetches all orders for consumer1, including the restaurant name and delivery status, in a single request:
curl:
The GraphQL endpoint accepts both
GET and POST requests. Use POST with a JSON body for all production queries — GET does not support variables.Next steps
GraphQL schema reference
Browse every type, query, mutation, and field in the FTGO GraphQL schema.