def __call__(self, resolver: Callable) -> Callable: if not iscoroutinefunction(resolver): raise NonAwaitableResolver( "The resolver `{}` given is not awaitable.".format( repr(resolver) ) ) SchemaRegistry.register_resolver(self._schema_name, self) self._implementation = resolver return resolver
def __call__(self, implementation: Callable) -> Callable: """ Registers the resolver into the schema. :param implementation: implementation of the resolver :type implementation: Callable :return: the implementation of the resolver :rtype: Callable """ if not is_valid_coroutine(implementation): raise NonAwaitableResolver( f"The resolver `{repr(implementation)}` given is not awaitable." ) if self._type_resolver is not None and not callable( self._type_resolver): raise NonCallable( "The < type_resolver > parameter of the resolver " f"`{repr(implementation)}` has to be a callable.") SchemaRegistry.register_resolver(self._schema_name, self) self._implementation = implementation return implementation