I have multiple graphql query types. I wish to apply middleware to one query type only for authentication. Is this possible?
Something like this
app.use(
'/s',
(request, response, next) => {
if (request.body.message === 'delete') {
auth();
}
next();
},
graphqlHTTP({
schema: require('./r/s').schema(),
graphiql: true,
})
);
The issue is that the format of the body is not JSON.
Maybe I am taking the wrong approach.