Skip to main content

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.

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.

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.
The schema is built with graphql-tools and served through Apollo Server on Express.

Architecture

Client


GraphQL Gateway  (Node.js + TypeScript, port 3000 / host port 8088)

  ├── OrderServiceProxy      → ORDER_HISTORY_SERVICE_URL  (default :8080)
  ├── ConsumerServiceProxy   → CONSUMER_SERVICE_URL       (default :8080)
  └── RestaurantServiceProxy → RESTAURANT_SERVICE_URL     (default :8080)
The gateway creates a fresh set of service proxies per request so that DataLoader batching is scoped to a single incoming GraphQL operation.

Queries and mutations

OperationTypeDescription
orders(consumerId)QueryReturns all orders placed by a consumer
order(orderId)QueryReturns a single order by ID
consumer(consumerId)QueryReturns a consumer and optionally their orders
createConsumer(c)MutationCreates a new consumer and returns the created record
Each 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 in docker-compose-api-gateway-graphql.yml. Start it alongside the dependent services:
docker-compose -f docker-compose-api-gateway-graphql.yml up
The gateway is mapped to host port 8088 (container port 3000):
http://localhost:8088/graphql

Environment variables

VariableDefaultDescription
ORDER_HISTORY_SERVICE_URLhttp://localhost:8080Base URL for the Order History Service
CONSUMER_SERVICE_URLhttp://localhost:8080Base URL for the Consumer Service
RESTAURANT_SERVICE_URLhttp://localhost:8080Base URL for the Restaurant Service

Building and running locally

npm install
npm run build   # compiles TypeScript to dist/
npm start       # runs dist/index.js
The server listens on port 3000 by default.

Example query

The following query fetches all orders for consumer 1, including the restaurant name and delivery status, in a single request:
query {
  orders(consumerId: 1) {
    orderId
    restaurant {
      id
      name
    }
    deliveryInfo {
      status
      estimatedDeliveryTime
      assignedCourier
    }
  }
}
Send it with curl:
curl http://localhost:8088/graphql \
  -X POST \
  -H "Content-Type: application/json" \
  --data '{"query":"{ orders(consumerId:1) { orderId, restaurant { name } } }"}'
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.

Build docs developers (and LLMs) love