My current workaround is to disable caching in the config and then register a custom copy of \Statamic\GraphQl\Middleware\CacheResponse::class that utilizes DefaultCache after my middleware again, but that's obviously far from best practice.
Maybe we should expose the whole middleware array like routes?
It would be nice to be able to configure GraphQL middlewares that run before
CacheResponse
.A use case would be a simple token authentication middleware. You would want to verify the token before you return a cached result. Currently,
CacheResponse
is always registered first: https://github.com/statamic/cms/blob/b5aeb0f0f57f5ecd0b62d11395eb5f81ea4bcc15/src/GraphQL/DefaultSchema.php#L76-L83My current workaround is to disable caching in the config and then register a custom copy of
\Statamic\GraphQl\Middleware\CacheResponse::class
that utilizesDefaultCache
after my middleware again, but that's obviously far from best practice.Maybe we should expose the whole middleware array like routes?