federation
federation copied to clipboard
[Federation] Pass existing GraphQLSchema to buildFederatedSchema.
Just bringing it to the issues area to give it a few eye-balls, feel free to close if it's not wanted or correct.
https://github.com/apollographql/apollo-server/pull/3013
This PR adds support to decorate existing schemas with federation add-ons. While working on the implementation of federation
in type-graphql
(https://github.com/19majkel94/type-graphql/pull/369), I realized that it's sort of a pain and pointless to convert from GraphQLSchema
to SDL and back and to SDL again as well as pluck out the GraphQL*Type
resolvers when buildFederatedSchema
should just be able to take in an already constructed schema and modify it.
@jbaxleyiii mind giving apollographql/apollo-server#3013 a review?
Is this going to go anywhere? It is a feature I would really like to see!
I will add that modifying an existing schema would really only be able to add the Federation type definitions. The Apollo function buildSubgraphSchema
wouldn't have enough context to know what other resolvers you might want to add like __resolveReference
. So really what you need to do is just add some directives to an existing schema. That can be done today with tools like graphql-tools merge.
I have a working example of how to do exactly that here: https://github.com/apollosolutions/add-federated-types
This takes some existing SDL and adds merges it with the Federation spec. It will not be able to add resolvers for you but it is a way to "automatically" include the @link
directives if you want or add @key
to certain types