I am using below latest versions & migrating to @apollo/server v4
"@apollo/gateway": "2.4.8",
"@apollo/server": "4.7.4",
"graphql": "16.6.0",
"type-graphql": "1.1.1",
Rest other errors solved but now getting the below error, do anyone have idea, I searched a lot but not getting what I am missing.
below is code snippet,
import { ApolloGateway, IntrospectAndCompose, RemoteGraphQLDataSource } from '@apollo/gateway';
class AuthenticatedDataSource extends RemoteGraphQLDataSource {
willSendRequest({ request, context }) {
// Pass the user's id from the context to underlying services
// as a header called `user-id`
}
}
const gateway = new ApolloGateway({
supergraphSdl: new IntrospectAndCompose({
subgraphs: [
{ name: "userService", url: "http://localhost:4001" }
]
}),
buildService({ name, url }) {
return new AuthenticatedDataSource({ url });
},
});
& my node version is : 18.13.0 & npm 8.19.3
but getting below error,
error: Error: A valid schema couldn't be composed. The following composition errors were found:
Invalid definition for directive "@tag": "@tag" should have locations FIELD_DEFINITION, OBJECT, INTERFACE, UNION, ARGUMENT_DEFINITION, SCALAR, ENUM, ENUM_VALUE, INPUT_OBJECT, INPUT_FIELD_DEFINITION, but found (non-subset) FIELD_DEFINITION, OBJECT, INTERFACE, UNION, ARGUMENT_DEFINITION, SCALAR, ENUM, ENUM_VALUE, INPUT_OBJECT, INPUT_FIELD_DEFINITION, SCHEMA
at IntrospectAndCompose.createSupergraphFromSubgraphList (/home/node/app/node_modules/@apollo/gateway/src/supergraphManagers/IntrospectAndCompose/index.ts:118:13)
at IntrospectAndCompose.updateSupergraphSdl (/home/node/app/node_modules/@apollo/gateway/src/supergraphManagers/IntrospectAndCompose/index.ts:106:32)
at processTicksAndRejections (node:internal/process/task_queues:95:5)
at async IntrospectAndCompose.initialize (/home/node/app/node_modules/@apollo/gateway/src/supergraphManagers/IntrospectAndCompose/index.ts:62:30)
at async ApolloGateway.initializeSupergraphManager (/home/node/app/node_modules/@apollo/gateway/src/index.ts:394:22)
at async ApolloGateway.load (/home/node/app/node_modules/@apollo/gateway/src/index.ts:304:7)