throw new apollo_graphql_1.GraphQLSchemaValidationError(errors);
^
GraphQLSchemaValidationError: Unknown directive "search".
at ApolloGateway.createSchema (/Users/geoffreynunan/Documents/GitHub/Libre-server/node_modules/@apollo/gateway/dist/index.js:207:19)
at ApolloGateway.<anonymous> (/Users/geoffreynunan/Documents/GitHub/Libre-server/node_modules/@apollo/gateway/dist/index.js:178:32)
at Generator.next (<anonymous>)
at fulfilled (/Users/geoffreynunan/Documents/GitHub/Libre-server/node_modules/@apollo/gateway/dist/index.js:5:58)
at processTicksAndRejections (node:internal/process/task_queues:94:5) {
errors: [
GraphQLError: Unknown directive "search".
at Object.Directive (/Users/geoffreynunan/Documents/GitHub/Libre-server/node_modules/graphql/validation/rules/KnownDirectives.js:61:29)
at Object.enter (/Users/geoffreynunan/Documents/GitHub/Libre-server/node_modules/graphql/language/visitor.js:324:29)
at visit (/Users/geoffreynunan/Documents/GitHub/Libre-server/node_modules/graphql/language/visitor.js:242:26)
at Object.validateSDL (/Users/geoffreynunan/Documents/GitHub/Libre-server/node_modules/graphql/validation/validate.js:93:22)
at buildSchemaFromDefinitionsAndExtensions (/Users/geoffreynunan/Documents/GitHub/Libre-server/node_modules/@apollo/federation/dist/composition/compose.js:150:25)
at Object.composeServices (/Users/geoffreynunan/Documents/GitHub/Libre-server/node_modules/@apollo/federation/dist/composition/compose.js:221:30)
at Object.composeAndValidate (/Users/geoffreynunan/Documents/GitHub/Libre-server/node_modules/@apollo/federation/dist/composition/composeAndValidate.js:13:41)
at ApolloGateway.createSchema (/Users/geoffreynunan/Documents/GitHub/Libre-server/node_modules/@apollo/gateway/dist/index.js:199:49)
at ApolloGateway.<anonymous> (/Users/geoffreynunan/Documents/GitHub/Libre-server/node_modules/@apollo/gateway/dist/index.js:178:32)
at Generator.next (<anonymous>) {
locations: [ { line: 14, column: 15 } ]
}
]
}
error Command failed with exit code 1.
Here is the apollo gateway index.js file
const { ApolloServer } = require('apollo-server');
const { ApolloGateway } = require("@apollo/gateway");
const gateway = new ApolloGateway({
serviceList: [
{ name: 'core', url: 'http://localhost:8080/graphql' }
],
});
const server = new ApolloServer({
gateway,
subscriptions: false,
});
server.listen().then(({ url }) => {
console.log(`🚀 Server ready at ${url}`);
});
Apollo Federation is giving errors because search directive is not defined in the schema provided.
On receiving GraphQL schema from Users, Dgraph generates a schema which adds definition for all Dgraph specific directives. This generated schema can then be used with Apollo Federation.
I tried to reproduce it but things are working fine for me.
I first started a Dgraph GraphQL service and applied the given schema.
Then I started the Gateway and there was no issue reported.
Did you do something different than this?
How are applying your schema?
Can you tell exact steps to reproduce so that we might help you better?
Then, using the following index.js for the graphql gateway, start the gateway with node index.js
const { ApolloServer } = require('apollo-server');
const { ApolloGateway } = require("@apollo/gateway");
const gateway = new ApolloGateway({
serviceList: [
{ name: 'core', url: 'http://localhost:8080/graphql' }
],
});
const server = new ApolloServer({
gateway,
subscriptions: false,
});
server.listen().then(({ url }) => {
console.log(`🚀 Server ready at ${url}`);
});
I get the following error
GraphQLSchemaValidationError: Unknown directive "search".
at ApolloGateway.createSchema (/Users/geoffreynunan/Documents/GitHub/Libre-server/node_modules/@apollo/gateway/dist/index.js:207:19)
at ApolloGateway.<anonymous> (/Users/geoffreynunan/Documents/GitHub/Libre-server/node_modules/@apollo/gateway/dist/index.js:178:32)
at Generator.next (<anonymous>)
at fulfilled (/Users/geoffreynunan/Documents/GitHub/Libre-server/node_modules/@apollo/gateway/dist/index.js:5:58)
at processTicksAndRejections (node:internal/process/task_queues:94:5) {
errors: [
GraphQLError: Unknown directive "search".
at Object.Directive (/Users/geoffreynunan/Documents/GitHub/Libre-server/node_modules/graphql/validation/rules/KnownDirectives.js:61:29)
at Object.enter (/Users/geoffreynunan/Documents/GitHub/Libre-server/node_modules/graphql/language/visitor.js:324:29)
at visit (/Users/geoffreynunan/Documents/GitHub/Libre-server/node_modules/graphql/language/visitor.js:242:26)
at Object.validateSDL (/Users/geoffreynunan/Documents/GitHub/Libre-server/node_modules/graphql/validation/validate.js:93:22)
at buildSchemaFromDefinitionsAndExtensions (/Users/geoffreynunan/Documents/GitHub/Libre-server/node_modules/@apollo/federation/dist/composition/compose.js:150:25)
at Object.composeServices (/Users/geoffreynunan/Documents/GitHub/Libre-server/node_modules/@apollo/federation/dist/composition/compose.js:221:30)
at Object.composeAndValidate (/Users/geoffreynunan/Documents/GitHub/Libre-server/node_modules/@apollo/federation/dist/composition/composeAndValidate.js:13:41)
at ApolloGateway.createSchema (/Users/geoffreynunan/Documents/GitHub/Libre-server/node_modules/@apollo/gateway/dist/index.js:199:49)
at ApolloGateway.<anonymous> (/Users/geoffreynunan/Documents/GitHub/Libre-server/node_modules/@apollo/gateway/dist/index.js:178:32)
at Generator.next (<anonymous>) {
locations: [ { line: 15, column: 22 } ]
}
]
}
If I remove the @search directive from the dgraph schema, the gateway starts successfully