Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support isinstance() checks in the base types #828

Merged
merged 2 commits into from Apr 12, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 4 additions & 1 deletion ariadne/types.py
Expand Up @@ -10,7 +10,7 @@
Type,
Union,
)
from typing_extensions import Protocol
from typing_extensions import Protocol, runtime_checkable

from graphql import (
DocumentNode,
Expand Down Expand Up @@ -46,6 +46,7 @@
ExtensionList = Optional[List[Union[Type["Extension"], Callable[[], "Extension"]]]]


@runtime_checkable
class Extension(Protocol):
def request_started(self, context: ContextValue):
pass # pragma: no cover
Expand All @@ -68,13 +69,15 @@ def format(self, context: ContextValue) -> Optional[dict]:
pass # pragma: no cover


@runtime_checkable
class ExtensionSync(Extension):
def resolve(
self, next_: Resolver, parent: Any, info: GraphQLResolveInfo, **kwargs
): # pylint: disable=invalid-overridden-method
return next_(parent, info, **kwargs)


@runtime_checkable
class SchemaBindable(Protocol):
def bind_to_schema(self, schema: GraphQLSchema) -> None:
pass # pragma: no cover