0
votes

In Rest API, if you want to set a middleware just for a specific route, you can use this for example:

router
  .route('/top-5-cheap')
  .get(tourControllers.middleAliasApi, tourControllers.getAllTours);

so in this case, middleAliasApi middleware is executed only if the user sends a request to this route.

How can i do the same in Graphql app? For example, execute a middleware only if the user queries a specific resolver. I'm using Apollo-express-server in backend.