Apollo Federation help and sample
See original GitHub issueHi @Shane32 @joemcbride @sungam3r2022 ,
I created a Github repo and added detailed explanations and steps in README. Please check it out. Structure is like;
D:\DEV\GIT\GRAPHQL.NET-IN-APOLLO-FEDERATION
├───country-subgraph
│ └───src
│ └───country
│ ├───dto
│ └───entities
├───federation-gateway
│ └───src
├───food-subgraph
│ └───src
│ └───restaurant
│ ├───dto
│ └───entities
└───starwars-subgraph
├───StarWars
│ └───Types
└───WebApi
├───Controllers
└───Properties
country-subgraph, food-subgraph & federation-gateway are created by NestJS and use ApolloServer. Gateway don’t care if the subgraphs are code-firts or SDL-first. While the country-subgraph is code-first, food-subgraph is SDL-first. They’re functional. You can try it following the steps in README.
starwars-subgraph is created with GraphQL.NET 4.7.1. You can add it to gateway just uncommenting a few lines . Below errors occur when added,
(node:3892) UnhandledPromiseRejectionWarning: Error: Couldn't load service definitions for "starwars"
at C:\murat\graphql.net-apollo-federation\federation-gateway\node_modules\@apollo\gateway\src\supergraphManagers\IntrospectAndCompose\loadServicesFromRemoteEndpoint.ts:77:15
at processTicksAndRejections (internal/process/task_queues.js:95:5)
at async Promise.all (index 2)
at loadServicesFromRemoteEndpoint (C:\murat\graphql.net-apollo-federation\federation-gateway\node_modules\@apollo\gateway\src\supergraphManagers\IntrospectAndCompose\loadServicesFromRemoteEndpoint.ts:81:30)
at IntrospectAndCompose.updateSupergraphSdl (C:\murat\graphql.net-apollo-federation\federation-gateway\node_modules\@apollo\gateway\src\supergraphManagers\IntrospectAndCompose\index.ts:95:20)
at IntrospectAndCompose.initialize (C:\murat\graphql.net-apollo-federation\federation-gateway\node_modules\@apollo\gateway\src\supergraphManagers\IntrospectAndCompose\index.ts:65:30)
at ApolloGateway.initializeSupergraphManager (C:\murat\graphql.net-apollo-federation\federation-gateway\node_modules\@apollo\gateway\src\index.ts:456:22)
at ApolloGateway.load (C:\murat\graphql.net-apollo-federation\federation-gateway\node_modules\@apollo\gateway\src\index.ts:351:7)
at SchemaManager.start (C:\murat\graphql.net-apollo-federation\federation-gateway\node_modules\apollo-server-core\src\utils\schemaManager.ts:111:22)
at ApolloServer._start (C:\murat\graphql.net-apollo-federation\federation-gateway\node_modules\apollo-server-core\src\ApolloServer.ts:359:24)
I guess, Apollo Gateway sends an introspection query and it failes. I may be doing something wrong, not sure. Maybe it can be fixed easily.
Importance of being able to add our graphql.net as subgraph to an existing Apollo Federation is really huge. When we achieve it, we’ll be able to use our legacy codebases which are in Graphql.Net 2. We’ll just upgrade to 4.7.1 and add it to our Apollo Server. So, we won’t need to change the codebase! Would be wonderful 😃
As seen here, we’re not trying to create the gateway with Graphql.Net. Gateway already exists. Apollo Federation is running. We just need to add our GraphQL.Net 4 app as a subgraph.
I’d send a PR for this sample gladly, when we put it to a final shape. I’d like to help for this in any way I can…
Thanks & regards
_Originally posted by @killjoy2013 in https://github.com/graphql-dotnet/examples/issues/91#issuecomment-1059769411_
Issue Analytics
- State:
- Created 2 years ago
- Comments:5
Thanks for the example @killjoy2013. It will help me when I return to my work on Federation.
I found this documentation some time ago and keep it opened among one of the ~200 other tabs in order not to forget.