@envelop/apollo-federation
Version:
This plugin integrates Apollo Federation Gateway into Envelop.
38 lines (29 loc) • 796 B
Markdown
This plugin integrates Apollo Federation Gateway into Envelop.
```
yarn add @envelop/apollo-federation
```
```ts
import { envelop } from '@envelop/core'
import { ApolloGateway } from '@apollo/gateway'
import { useApolloFederation } from '@envelop/apollo-federation'
// Initialize the gateway
const gateway = new ApolloGateway({
serviceList: [
{ name: 'accounts', url: 'http://localhost:4001' },
{ name: 'products', url: 'http://localhost:4002' }
// ...additional subgraphs...
]
})
// Make sure all services are loaded
await gateway.load()
// Then pass it to the plugin configuration
const getEnveloped = envelop({
plugins: [
// ... other plugins ...
useApolloFederation({ gateway })
]
})
```