apollographql / apollographql/federation
Multi-level Federation
- Dominant language
- TypeScript
- Stars
- 725
- Forks
- 276
- Avg merge
- 1h 47m
- Merged PRs (30d)
- 1
Description
The idea of composing all the GraphQL services across the organization declaratively is very useful indeed.
Currently, we're evaluating Federation and have stumbled upon an interesting (hopefully) question– What does the team think or have any plan on having multiple levels of federation?
I think the question above can be broken down into two:
1. Is it something practical or even desirable to have multiple levels of federation? Do other companies see value in it? Or it is just a crazy idea?
2. If the answer is YES to above, what are the possibilities currently to achieve it in the current form of federation?
To give an example:
```
┌───────────┐ ┌───────────┐
│Mobile App │ │ Web App │
└───────────┘ └───────────┘
▲ ▲
│ │
│ │
│ │
┌──────────────────────┐ ┌──────────────────────┐
│Mobile Graph (Gateway)│ │ Web Graph (Gateway) │
└──────────────────────┘ └──────────────────────┘
▲ ▲ ▲ ▲ ▲ ▲
│ │ │ │ │ │
│ │ │ │ │ │
│ │ │ │ │ │
┌───────────┐ │ ┌──────────────┐ │ ┌───────────┐
│Mobile BFF │ │ │ Common BFF │ │ │ Web BFF │
└───────────┘ │ └──────────────┘ │ └───────────┘
│ │
│ │
│ │
│ │
┌─────────────────────────────────────────────────────────┐
│ Domain Graph (Gateway) │
└─────────────────────────────────────────────────────────┘
▲ ▲ ▲ ▲
│ │ │ │
│ │ │ │
│ │ │ │
┌───────────┐ ┌───────────┐ ┌───────────┐ ┌───────────┐
│ Accounts │ │ Reviews │ │ Payment │ │ Users │
└───────────┘ └───────────┘ └───────────┘ └───────────┘
```
Where,
- Accounts, Reviews, Payments, Users etc are the core services. The Domain Graph could be exposed to other services that do not need to worry about the UI part of the schema.
- BFFs hold schema that is more close to the UI/Product of the application. It is federated by the Domain Graph, Common UI schema, and the app-specific schemas (maintained by respective teams).
I hope the explanation was clear enough. Happy to answer questions.
Contributor guide
Research direction
Start with the multi-level federation architecture and questions described in the issue body, including the Domain Graph and BFF layers. The issue names no files, tests, or entry points; done would require a decided approach or documented answer about whether and how nested federation should work.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- graphql
- Domain
- api, backend-api-design
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100