Open
Description
Split from #1000.
I have a similar use case with Ariadne middleware functions, but with kwargs
. In Ariadne, a "resolver" function takes two positional arguments and a varying number of keyword arguments that depend on the API the resolver implements. As the name implies, a middleware function sits between Ariadne and the resolver function and forwards arguments.
Ideally, I would like to type a middleware function as follows:
_P = ParamSpec("_P")
_R = TypeVar("_R")
_T = TypeVar("_T")
def foo_middleware(
resolver: Callable[Concatenate[_T, GraphQLResolveInfo, _P], _R],
obj: _T,
info: GraphQLResolveInfo,
/,
**kwargs: _P.kwargs,
) -> _R:
...
return resolver(obj, info, **kwargs)
But currently this isn't possible, because _P.args
is "missing".