GraphQL Middleware

There are 2 kind of middlewares,

  • Global Middleware : All middleware files kept under ./server/middleware/ will be called for every api call.
  • Resolver Specific Middleware 1 : These middleware files are kept under the respective resolver folder and will be called for the query/mutation within that resolver.
    Example : resolver path - ./server/resolvers/primary/blog/blog.resolver.js
    and middleware file path - ./server/resolvers/primary/blog/blog.middleware.js
  • Resolver Specific Middleware 2 : This middleware also gets invoked during the resolving of nested queries and in that case the last argument ids would be an array of parent ids of the query.

Each middleware is a subclass of BaseMiddlewareGql and will have method called default.

Lifecycle Diagram


GraphQL API



GraphQL API


Subscribe to Our Newsletter

Let us stretch your imagination

Download App