Prior to using graphql-middleware when initializing our apollo server I was simply passing our schema and typeDefs directly to the apollo server upon instantiation.
// instantiate apollo server
this._gServer = new ApolloServer({
typeDefs: GraphqlTypeDefs.getTypeDefs(),
resolvers: GraphqlResolvers.getMap(),
schemaDirectives: {
directive1: Directive1,
...
}
...
});
However I am using the makeExecutableSchema and applyMiddleware functions as prescribed, and while the middleware itself is being executed as expected, our custom schema directives are no longer being executed. The code I'm using to initialize the server is as follows:
// make an executable schema
const schema: GraphQLSchema = makeExecutableSchema({
typeDefs: GraphqlTypeDefs.getTypeDefs(),
resolvers: GraphqlResolvers.getMap()
});
// apply middlewares to the schema
const schemaWithMiddleware: GraphQLSchemaWithFragmentReplacements =
applyMiddleware(schema, GraphqlPrePostApiEndpointMiddleware.execute);
// instantiate apollo server
this._gServer = new ApolloServer({
schema: schemaWithMiddleware, // not working with directives
schemaDirectives: {
directive1: Directive1,
...
}
...
});
Can advise how I might get directives working with graphql-middleware?
I just realized, after poking around, that applyMiddleware also takes schemaDirectives as an option, and passing them there fixed my issues. Apologies.
Hi There,
Prior to using
graphql-middleware
when initializing our apollo server I was simply passing ourschema
andtypeDefs
directly to the apollo server upon instantiation.However I am using the
makeExecutableSchema
andapplyMiddleware
functions as prescribed, and while the middleware itself is being executed as expected, our custom schema directives are no longer being executed. The code I'm using to initialize the server is as follows:Can advise how I might get directives working with
graphql-middleware
?