A library that retrofits GraphQL federation support (Apollo Federation spec) onto an existing GraphQL schema that was not originally built for federation. v2.2.0 is current, with stable maintenance releases. Unlike apollo-server's built-in federation, this works with remote schemas, generated schemas, or any schema you can't rebuild from scratch. It adds @key, @external, @provides, @requires directives and __resolveReference resolvers. Requires graphql 14/15 and @apollo/federation 0.x peer dependencies. Ships TypeScript types.
npm install graphql-transform-federationNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows how to wrap a remote GraphQL schema with federation directives and a __resolveReference resolver for a Product type.
Update config objects: use 'keyFields: ["id"]' instead of 'key: ["id"]', and 'fields: { id: { external: true } }' instead of 'fields: ["id"]'.If using Apollo Server 3+, use '@apollo/subgraph' (though this library may not fully support it yet – check compatibility).
Provide a resolveReference callback that calls delegateToSchema or fetches data from the original source.
Use @apollo/federation@0.x that is compatible with graphql 14/15. Check peerDependencies in package.json.
Double-check all object type names, field names, and key fields exist in the original schema. Use TypeScript for compile-time checks.
npm install @apollo/federation@0.x
Add keyFields and resolveReference to the federationConfig for that type.
Use import { transformSchemaFederation } from 'graphql-transform-federation';Use 'keyFields' (array of strings) and 'fields' (object mapping to FederationFieldConfig) instead.