mercurius-gateway
mercurius-gateway copied to clipboard
Federation: strip common directives from federate services schema
While working on https://github.com/mcollina/fastify-gql/pull/227 and https://github.com/mcollina/fastify-gql/issues/184 I have noticed that the fastify-gql implementation is lacking at least two features from Apollo server.
One of them is that apollo server strips common and type system directives definitions (i.e the definition of key
directive) from federated services sdl before combining them.
As stated in their documentation this allows the federated service to provide the schema unchanged without needing to strip them out.
Documentation: https://www.apollographql.com/docs/apollo-server/federation/gateway/#type-system-directives Apollo's code: https://github.com/apollographql/apollo-server/blob/1c58ea3cbf6f5ead1afd5e81a1113a75441ead26/packages/apollo-federation/src/composition/composeAndValidate.ts#L16 https://github.com/apollographql/apollo-server/blob/main/packages/apollo-federation/src/composition/normalize.ts#L20 https://github.com/apollographql/apollo-server/blob/main/packages/apollo-federation/src/composition/normalize.ts#L270
Tests: https://github.com/apollographql/apollo-server/blob/main/packages/apollo-federation/src/composition/tests/normalize.test.ts#L147