Middleware#
Cannula provides a handful of middleware resolvers with aid in the development process. These middleware resolvers intercept the default resolvers and alter the request/response to provide useful information or completely replace the default resolvers.
Debug Middleware#
Use this middleware to log details about the queries that you are running.
By default this will use logging.debug and will use the cannula logger. You can override that when you setup the middleware.
Example with Cannula API#
import cannula
from cannula.middleware import DebugMiddleware
api = cannula.CannulaAPI(
__name__,
schema=SCHEMA,
middleware=[
DebugMiddleware(),
],
)
Example with graphql-core-next#
You can optionally use this middleware as a standalone with the graphql-core-next:
from cannula.middleware import DebugMiddleware
from graphql import graphql
graphql(
schema=SCHEMA,
query=QUERY,
middleware=[
DebugMiddleware(),
],
)