An attempt at setting up a federated GraphQL server, containing a local gateway router and two subgraphs
Directories are:
router/
: (NodeJS) Contains the router gateway and supergraphauthors/
: (NodeJS) Contains subgraph A (Authors, extension of Book)publishers/
: (NodeJS) Contains subgraph B (Publisher, extension of Author)books/
: (Elixir/Absinthe) Contains subgraph B (Book, extension of Author)
- Bun
- Elixir
- Apollo Rover CLI tool https://www.apollographql.com/docs/rover
bun install
in each directory
The node APIs just have hardcoded GraphQL SDL since this is the easiest path with Apollo Server.
In the Elixir API (books), use the custom mix task mix sdl
. This uses the Absinthe Federation wrapper to generate the federation version of the SDL.
From within the router/
directory, run bun run supergraph:compose
. The supergraph will output to router/src/supergraph.graphql
- Gateway:
- From within
router/
, runbun start
- From within
- Authors subgraph:
- From within
authors/
, runbun start
- From within
- Publishers subgraph:
- From within
publishers/
, runbun start
- From within
- Books subgraph:
- From within
books
, runmix phx.server
- From within