Configure Apollo Federation DataSource
Published: 2022-05-23
WunderGraph is a complete replacement for the Apollo Federation Gateway.
Simply pass all your services endpoints to the introspect.federation
func and you're almost there.
Once you have it introspected, pass it to the Application and you're good to go.
All this can happen "offline", during development or in your CD pipeline. There will be no introspection in production. You can fully disable introspection once you're shipping to prod.
const federatedApi = introspect.federation({apiNamespace: "federation",upstreams: [{url: "http://localhost:4001/graphql"},{url: "http://localhost:4002/graphql"},{url: "http://localhost:4003/graphql"},{url: "http://localhost:4004/graphql",},]});
If you're looking into more details on configuring static and dynamic upstream headers, have a look at the dedicated configuration section on configuring Headers for HTTP-based APIs.