Exemplo n.º 1
0
    def __call__(self, implementation: Callable) -> Callable:
        if not isasyncgenfunction(implementation):
            raise NonAsyncGeneratorSubscription(
                "The subscription `{}` given is not an awaitable "
                "generator.".format(repr(implementation)))

        SchemaRegistry.register_subscription(self._schema_name, self)
        self._implementation = implementation
        return implementation
Exemplo n.º 2
0
    def __call__(self, implementation: Callable) -> Callable:
        """
        Registers the subscription generator into the schema.
        :param implementation: implementation of the subscription generator
        :type implementation: Callable
        :return: the implementation of the subscription generator
        :rtype: Callable
        """
        if not is_valid_async_generator(implementation):
            raise NonAsyncGeneratorSubscription(
                "The subscription < {} > given is not an awaitable "
                "generator.".format(repr(implementation)))

        SchemaRegistry.register_subscription(self._schema_name, self)
        self._implementation = implementation
        return implementation