Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions rath/contrib/fakts/__init__.py

This file was deleted.

7 changes: 0 additions & 7 deletions rath/contrib/fakts/links/__init__.py

This file was deleted.

53 changes: 0 additions & 53 deletions rath/contrib/fakts/links/aiohttp.py

This file was deleted.

47 changes: 0 additions & 47 deletions rath/contrib/fakts/links/graphql_ws.py

This file was deleted.

47 changes: 0 additions & 47 deletions rath/contrib/fakts/links/httpx.py

This file was deleted.

47 changes: 0 additions & 47 deletions rath/contrib/fakts/links/subscription_transport_ws.py

This file was deleted.

6 changes: 0 additions & 6 deletions rath/contrib/herre/links/__init__.py

This file was deleted.

19 changes: 0 additions & 19 deletions rath/contrib/herre/links/auth.py

This file was deleted.

19 changes: 14 additions & 5 deletions rath/links/aiohttp.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from http import HTTPStatus
import json
from ssl import SSLContext
from typing import Any, Dict, List, Optional, Type, AsyncIterator
from typing import Any, Dict, List, Optional, Self, Type, AsyncIterator
from rath.links.types import Payload
import aiohttp
from graphql import OperationType
Expand Down Expand Up @@ -43,7 +43,11 @@ class AIOHttpLink(AsyncTerminatingLink):
"""ssl_context is the SSLContext to use for the aiohttp session. By default, this
is a context that uses the certifi CA bundle."""

auth_errors: List[HTTPStatus] = Field(default_factory=lambda: (HTTPStatus.FORBIDDEN,))
auth_errors: List[HTTPStatus] = Field(
default_factory=lambda: [
HTTPStatus.FORBIDDEN,
]
)
"""auth_errors is a list of HTTPStatus codes that indicate that the request was
unauthorized. By default, this is just HTTPStatus.FORBIDDEN, but you can
override this to include other status codes that indicate that the request was
Expand All @@ -56,9 +60,9 @@ class AIOHttpLink(AsyncTerminatingLink):

_connected = False

async def __aenter__(self) -> None:
async def __aenter__(self) -> Self:
"""Entery point for the async context manager"""
pass
return self

async def aconnect(self, operation: Operation) -> None:
"""Connects the link to the server
Expand All @@ -69,7 +73,12 @@ async def aconnect(self, operation: Operation) -> None:
"""
self._connected = True

async def __aexit__(self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], traceback: Optional[Any]) -> None:
async def __aexit__(
self,
exc_type: Optional[Type[BaseException]],
exc_val: Optional[BaseException],
traceback: Optional[Any],
) -> None:
"""Exit point for the async context manager"""
pass

Expand Down
19 changes: 13 additions & 6 deletions rath/links/base.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Any, AsyncIterator, Optional, Type
from typing import Any, AsyncIterator, Optional, Self, Type
from koil.composition import KoiledModel
from rath.operation import GraphQLResult, Operation
from rath.errors import NotComposedError
Expand All @@ -23,18 +23,25 @@ async def adisconnect(self) -> None:
"""A coroutine that is called when the link is disconnected."""
pass

async def __aenter__(self) -> None:
async def __aenter__(self) -> Self:
"""A coroutine that is called when the link is entered."""
pass

async def __aexit__(self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], traceback: Optional[Any]) -> None:
return self

async def __aexit__(
self,
exc_type: Optional[Type[BaseException]],
exc_val: Optional[BaseException],
traceback: Optional[Any],
) -> None:
"""A coroutine that is called when the link is exited."""
pass

def aexecute(self, operation: Operation) -> AsyncIterator[GraphQLResult]:
"""A coroutine that takes an operation and returns an AsyncIterator
of GraphQLResults. This method should be implemented by subclasses."""
raise NotImplementedError(f"Please overwrite the asubscribe method in {self.__class__.__name__}")
raise NotImplementedError(
f"Please overwrite the asubscribe method in {self.__class__.__name__}"
)


class TerminatingLink(Link):
Expand Down
Loading