I’m following the lesson here to learn more about Federation and Entities, and I’m sort of stuck on the step where the instructions ask you to add this to the schema files
When I add this line to the reviews.graphql and locations.graphql files both sub graph servers crash with the same error
Error: Unknown directive "@link".
at assertValidSDL (/Users/jvajda/Documents/Github/apollo-learning/odyssey-voyage-I/subgraph-reviews/node_modules/graphql/validation/validate.js:135:11)
at buildASTSchema (/Users/jvajda/Documents/Github/apollo-learning/odyssey-voyage-I/subgraph-reviews/node_modules/graphql/utilities/buildASTSchema.js:44:34)
at makeExecutableSchema (/Users/jvajda/Documents/Github/apollo-learning/odyssey-voyage-I/subgraph-reviews/node_modules/@graphql-tools/schema/cjs/makeExecutableSchema.js:73:47)
at Function.constructSchema (/Users/jvajda/Documents/Github/apollo-learning/odyssey-voyage-I/subgraph-reviews/node_modules/@apollo/server/dist/cjs/ApolloServer.js:315:50)
at new ApolloServer (/Users/jvajda/Documents/Github/apollo-learning/odyssey-voyage-I/subgraph-reviews/node_modules/@apollo/server/dist/cjs/ApolloServer.js:89:49)
at startApolloServer (/Users/jvajda/Documents/Github/apollo-learning/odyssey-voyage-I/subgraph-reviews/index.js:12:18)
at Object.<anonymous> (/Users/jvajda/Documents/Github/apollo-learning/odyssey-voyage-I/subgraph-reviews/index.js:35:1)
at Module._compile (node:internal/modules/cjs/loader:1105:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
I actually figured this out, but will leave this message for others, until you do this step correctly:
“where we initialized the ApolloServer, we’re now going to pass the existing typeDefs and resolvers properties as an object into the buildSubgraphSchema function. Then we’ll use the result to set a new ApolloServer configuration property called schema”
const server = new ApolloServer({
schema: buildSubgraphSchema({ typeDefs, resolvers }),
});
Thanks for bringing this up @jpvajda ! We briefly point out not to worry about the errors that pop up, it’s in the video at 3:45 and in the written content, but it’s definitely easy to miss!
@MichelleMabuyo This should probably be added to the Moving to Apollo Federation 2 docs The only place I saw mention of the change to how ApolloServer is called under Apollo Federation 2 was in this thread.