To interact with different microservices using Apollo Server and TypeScript, leveraged Apollo Federation to create a unified GraphQL API
Here’s a concise README.md
with instructions for the example setup:
This repository demonstrates how to set up Apollo Federation with TypeScript to interact with multiple microservices.
-
Navigate to the
serviceA
directory:cd serviceA
-
Install dependencies:
npm install
-
Start the Service A server:
npx tsc && node dist/index.js
-
Navigate to the
serviceB
directory:cd serviceB
-
Install dependencies:
npm install
-
Start the Service B server:
npx tsc && node dist/index.js
-
Navigate to the
gateway
directory:cd gateway
-
Install dependencies:
npm install
-
Start the Apollo Gateway server:
npx tsc && node dist/index.js
With all services running, you can query the unified API via the Apollo Gateway at http://localhost:4000
. For example, use a GraphQL client or Playground to execute:
{
hi
hello
}
Introspection is enabled to explore the schema. GraphQL Playground is available at http://localhost:4000
for interactive querying and schema exploration.
MIT
Feel free to modify this README as needed!