def __call__(self, implementation): if isclass(implementation): self._implementation = implementation() else: self._implementation = implementation SchemaRegistry.register_directive(self._schema_name, self) return implementation
def __call__(self, implementation): if not iscoroutinefunction(implementation.on_field_execution): raise NonAwaitableDirective("%s is not awaitable" % repr(implementation)) SchemaRegistry.register_directive(self._schema_name, self) self._implementation = implementation return implementation
def __call__(self, implementation: type) -> Any: """ Registers the directive into the schema. :param implementation: implementation of the directive :type implementation: type :return: the implementation of the directive :rtype: Any """ if isclass(implementation): self._implementation = implementation() else: self._implementation = implementation SchemaRegistry.register_directive(self._schema_name, self) return implementation