-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
buildFederatedSchema with existing GraphQLSchema #2965
Comments
You can get from a normal schema to a federation-capable one through the steps on our federation specification docs. In short, you just need to add a few fields and their resolvers to the schema, and define some directives. An alternative approach could be to use
I'd like to play around with this a bit more, but it looks like |
@JacksonKearl I just cloned the repository and copy / pasted a test and was going to add annotations to define federated schema. Would you say your first approach is best vs bringing on gql dependency? Also, I was just getting lost with how "decorators" are added to |
I was converting our |
PS. I was going about the manual way, but I'm unsure how to properly add directives to an ObjectType. |
I got part of the way doing this myself, before I ran into the same blocker you're having regarding directives. Looks like Might I suggest Apollo Client instead? 😉 |
Ah! I see you're already active here: MichalLytek/type-graphql#351 |
@JacksonKearl Hey! I started hacking at it and got 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 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 I'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 /cc @19majkel94 |
Thanks very much for reporting this! We think this is a great idea, and would definitely review a PR. If you (or anyone else) is interested in working on this, that would be great - thanks! |
@JacksonKearl |
I'm trying to implement
apollo-federation
intype-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.The text was updated successfully, but these errors were encountered: