apollographql / apollographql/federation
[Federation] How to override managed federation for local deployment?
- Dominant language
- TypeScript
- Stars
- 725
- Forks
- 276
- Avg merge
- 1h 47m
- Merged PRs (30d)
- 1
Description
As an organization that uses managed federation, we would like to develop a new federated service locally and compose it with the current composed graph today. One option of doing this is to override the `loadServiceDefinitions` method to change the provided service overrides.
I'm opening this issue as an overall discussion to solicit feedback from the community. I have a working MVP and would like to have it eventually committed to the public facing acephei example in this repo.
[Here](https://github.com/apollographql/apollo-server/blob/michael-watson/acephei-local-service-override/examples/acephei/gateway/src/localApolloGateway.ts) is a link to my proposed local solution. This code snippet would be similar to what teams would need to manage in order to override
To enable overriding a single service, the Apollo Gateway would respond to three environment variables being set:
`APOLLO_SERVICE_OVERRIDE=true`
`APOLLO_SERVICE_OVERRIDE_NAME` - name of the service to change url of
`APOLLO_SERVICE_OVERRIDE_URL` - local dev environment url
To enable override a list of services, the user would define a local json file that contains the list of ServiceDefinitions:
`APOLLO_SERVICE_OVERRIDE=localOverride.json` - assumes root directory, but can provide absolute path
`localOverride.json`:
```
{
"servicesToOverride": [
{
"name": "accounts",
"url": "http://localhost:4001"
}
]
}
```
[Here](https://github.com/apollographql/apollo-server/blob/michael-watson/acephei-local-service-override/examples/acephei/gateway/src/index.ts#L57) is an example of how the override gateway could be conditionally loaded up.
### Pros of current implementation
- local developers don't need to change code of gateway
- can clone gateway repo or startup gateway artifact with environment variables set
local json file can be put into .gitignore
- Can be modified for custom logic depending on the orgs needs
### Cons
- You tell me 😄
Any comments or feedback is much appreciated!
Contributor guide
Assessment
This issue has not been assessed yet.