buildFederatedSchema with existing GraphQLSchema
See original GitHub issueI’m trying to implement apollo-federation
in type-graphql
library which uses GraphQL*Type to construct schemas. Is it possible to build convert/build a federated schema from a GraphQLSchema? It seems like these libraries will have to convert to outputting SDL instead of using graphql-js directly.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:3
- Comments:9 (1 by maintainers)
Top Results From Across the Web
How to convert GraphqlSchema into a Federation Schema?
When I passing existing GrpahqlSchema to buildFederatedSchema , I am getting below error. Cannot read property 'kind' of undefined.
Read more >Introduction to Apollo Federation - Apollo GraphQL Docs
With federation, you can responsibly share ownership of your supergraph across any number of teams. And even if you currently only have one...
Read more >GraphQL Schema Federation With Apollo, TypeScript and ...
The last step is to make our schema available to be federated by the Gateway , by using buildFederatedSchema like we did before...
Read more >Best Practices for Designing a Federated GraphQL Schema
Learn GraphQL with Apollo Odyssey, our hands-on training and tutorial course platform - https://odyssey.apollographql.com/Learn from our ...
Read more >Your First Federated Schema with Apollo Server - YouTube
Talk by Mandi Wise, Author of Advanced GraphQL with Apollo & React and Owner, 8-Bit Press Inc.Since its launch last year, Apollo Federation ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@JacksonKearl Hey! I started hacking at it and got
type-graphql
to output a federation type of schema.The directive hack is here: https://github.com/19majkel94/type-graphql/pull/369/files#diff-48f4a1f7b529a17d4579df20f8af7af1R272
And here’s a quick test showing that it works (well prints schema correctly): https://github.com/19majkel94/type-graphql/pull/369/files#diff-b0c36f08a566dd0298fff8e07447781b
I mimic’d the demo reviews service.
I’m not sure if I break schema by using
astNode
instead ofextensionASTNodes
. I’d think I should useextensionASTNodes
but apollo federation doesn’t pull directives unless astNode IS defined and using typescript, I can’t have it be an empty object (https://github.com/apollographql/apollo-server/blob/master/packages/apollo-federation/src/service/printFederatedSchema.ts#L170).That directive issue you listed is so people can use directives more as middleware / validation / etc, whereas I believe federation just uses them for referencing schema and doesn’t do anything on a resolver level with them? So I thought I could implement them directly for now to see if I can get it to work. I believe I could create a
__resolveReference
field resolver withintype-graphql
, soI’m not too sure where to go from here though, haha. I was going about it the “manual” way you mentioned instead of using the
buildFederatedSchema
route./cc @19majkel94
@JacksonKearl type-graphql’s ResolversMap is designed to work with other tools, like
graphql-tools
- I’ve basically copied their types and refactored them a bit. TheResolverOptions
are responsible for handlingsubscribe
instead ofresolve
(not supported in federation) as well as__resolveType
and__isTypeOf
for unions and interfaces.