|
1 | 1 | from __future__ import annotations |
2 | 2 |
|
3 | 3 | import warnings |
4 | | -from typing import TYPE_CHECKING, Any, Optional, Union, cast |
| 4 | +from typing import TYPE_CHECKING, Optional, Union |
| 5 | + |
| 6 | +from lia import ChaliceHTTPRequestAdapter, HTTPException |
5 | 7 |
|
6 | 8 | from chalice.app import Request, Response |
7 | | -from strawberry.http.exceptions import HTTPException |
8 | | -from strawberry.http.sync_base_view import SyncBaseHTTPView, SyncHTTPRequestAdapter |
| 9 | +from strawberry.http.sync_base_view import SyncBaseHTTPView |
9 | 10 | from strawberry.http.temporal_response import TemporalResponse |
10 | 11 | from strawberry.http.typevars import Context, RootValue |
11 | 12 |
|
12 | 13 | if TYPE_CHECKING: |
13 | | - from collections.abc import Mapping |
14 | | - |
15 | 14 | from strawberry.http import GraphQLHTTPResponse |
16 | 15 | from strawberry.http.ides import GraphQL_IDE |
17 | | - from strawberry.http.types import HTTPMethod, QueryParams |
18 | 16 | from strawberry.schema import BaseSchema |
19 | 17 |
|
20 | 18 |
|
21 | | -class ChaliceHTTPRequestAdapter(SyncHTTPRequestAdapter): |
22 | | - def __init__(self, request: Request) -> None: |
23 | | - self.request = request |
24 | | - |
25 | | - @property |
26 | | - def query_params(self) -> QueryParams: |
27 | | - return self.request.query_params or {} |
28 | | - |
29 | | - @property |
30 | | - def body(self) -> Union[str, bytes]: |
31 | | - return self.request.raw_body |
32 | | - |
33 | | - @property |
34 | | - def method(self) -> HTTPMethod: |
35 | | - return cast("HTTPMethod", self.request.method.upper()) |
36 | | - |
37 | | - @property |
38 | | - def headers(self) -> Mapping[str, str]: |
39 | | - return self.request.headers |
40 | | - |
41 | | - @property |
42 | | - def post_data(self) -> Mapping[str, Union[str, bytes]]: |
43 | | - raise NotImplementedError |
44 | | - |
45 | | - @property |
46 | | - def files(self) -> Mapping[str, Any]: |
47 | | - raise NotImplementedError |
48 | | - |
49 | | - @property |
50 | | - def content_type(self) -> Optional[str]: |
51 | | - return self.request.headers.get("Content-Type", None) |
52 | | - |
53 | | - |
54 | 19 | class GraphQLView( |
55 | 20 | SyncBaseHTTPView[Request, Response, TemporalResponse, Context, RootValue] |
56 | 21 | ): |
|
0 commit comments