Skip to content

Commit 7ede4e3

Browse files
authored
feat: 适配最新 strawberry-graphql (#648)
顺便更新了其他所有依赖
1 parent 5061b01 commit 7ede4e3

File tree

5 files changed

+197
-192
lines changed

5 files changed

+197
-192
lines changed

home/storage/types.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
import strawberry
44
import strawberry_django
55
from django.db.models import Q
6-
from strawberry import relay
7-
from strawberry_django import FilterLookup
6+
from strawberry import Info, relay
7+
from strawberry_django import FilterLookup, StrFilterLookup
88

99
from home.users.types import User
1010

@@ -27,8 +27,8 @@ class PictureOrder:
2727
@strawberry.input
2828
class StorageFilterLookup:
2929
id: relay.GlobalID | None = strawberry.UNSET
30-
name: FilterLookup[str] | None = strawberry.UNSET
31-
description: FilterLookup[str] | None = strawberry.UNSET
30+
name: StrFilterLookup | None = strawberry.UNSET
31+
description: StrFilterLookup | None = strawberry.UNSET
3232
level: FilterLookup[int] | None = strawberry.UNSET
3333
is_null: bool | None = strawberry.UNSET
3434

@@ -122,9 +122,9 @@ class Picture(relay.Node):
122122
box_w: strawberry.auto
123123

124124
@strawberry.field
125-
def name(self, info) -> str:
125+
def name(self, info: Info) -> str:
126126
return self.picture.name.split("/")[-1] # type: ignore
127127

128128
@strawberry.field
129-
def url(self, info) -> str:
129+
def url(self, info: Info) -> str:
130130
return self.picture.url # type: ignore

home/tests.py

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -21,23 +21,6 @@ def authenticate(self, user):
2121
"""登录"""
2222
self.client.force_login(user)
2323

24-
def request(
25-
self,
26-
body: dict[str, object],
27-
headers: dict[str, object] | None = None,
28-
files: dict[str, object] | None = None,
29-
):
30-
kwargs: dict[str, object] = {"data": body}
31-
# 默认的测试客户端居然没用上 headers
32-
if headers:
33-
kwargs.update(headers)
34-
if files:
35-
kwargs["format"] = "multipart"
36-
else:
37-
kwargs["content_type"] = "application/json"
38-
39-
return self.client.post(self.path, **kwargs) # type: ignore
40-
4124
def execute(
4225
self,
4326
query: str,
@@ -50,7 +33,7 @@ def execute(
5033
5134
和之前的格式相同
5235
"""
53-
return super().query(query, variables, headers, asserts_errors, files) # type: ignore
36+
return super().query(query, variables, headers, files, asserts_errors) # type: ignore
5437

5538

5639
class GraphQLTestCase(TestCase):

home/users/tests.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ def test_get_session(self):
414414
}
415415
}
416416
"""
417-
content = self.client.execute(query, headers={"HTTP_X_FORWARDED_FOR": "1.1.1.1"})
417+
content = self.client.execute(query, headers={"X-Forwarded-For": "1.1.1.1"})
418418

419419
data = content.data["viewer"]["session"]
420420
# 必须排序确保新的会话在后面
@@ -433,7 +433,7 @@ def test_get_session(self):
433433

434434
# 再次请求,这次应该能够获取到正确的 IP 地址
435435
# 因为在上一次请求中,已经将 IP 地址写入到了 session 中
436-
content = self.client.execute(query, headers={"HTTP_X_FORWARDED_FOR": "1.1.1.1"})
436+
content = self.client.execute(query, headers={"X-Forwarded-For": "1.1.1.1"})
437437

438438
data = content.data["viewer"]["session"]
439439
data.sort(key=lambda x: x["isCurrent"])

pyproject.toml

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,25 +7,25 @@ readme = "README.md"
77
license = { file = "LICENSE" }
88
requires-python = ">=3.13.5"
99
dependencies = [
10-
"django>=5.2.8",
11-
"strawberry-graphql-django>=0.67.1",
10+
"django>=5.2.12,<6.0",
11+
"strawberry-graphql-django>=0.82.0",
1212
"channels>=4.3.2",
1313
"channels-redis[cryptography]>=4.3.0",
14-
"celery>=5.5.3",
14+
"celery>=5.6.2",
1515
"django-celery-beat>=2.8.1",
1616
"django-cleanup>=9.0.0",
1717
"django-mptt>=0.18.0",
1818
"django-storages[s3]>=1.14.6",
19-
"markdown>=3.10",
20-
"pillow>=12.0.0",
21-
"psycopg[binary]>=3.2.13",
22-
"sentry-sdk>=2.45.0",
19+
"markdown>=3.10.2",
20+
"pillow>=12.1.1",
21+
"psycopg[binary]>=3.3.3",
22+
"sentry-sdk>=2.54.0",
2323
"geoip2>=5.2.0",
2424
"httpx>=0.28.1",
25-
"gunicorn>=23.0.0",
26-
"uvicorn[standard]>=0.38.0",
25+
"gunicorn>=25.1.0",
26+
"uvicorn[standard]>=0.42.0",
2727
"uvicorn-worker>=0.4.0",
28-
"mozilla-django-oidc>=4.0.1",
28+
"mozilla-django-oidc>=5.0.2",
2929
]
3030

3131
[project.urls]
@@ -36,12 +36,12 @@ Changelog = "https://github.com/he0119/smart-home/blob/main/CHANGELOG.md"
3636

3737
[dependency-groups]
3838
dev = [
39-
"coverage>=7.12.0",
39+
"coverage>=7.13.4",
4040
"django-cors-headers>=4.9.0",
4141
"eventlet>=0.40.4",
4242
"daphne>=4.2.1",
43-
"strawberry-graphql-django[debug-toolbar]>=0.67.2",
44-
"poethepoet>=0.37.0",
43+
"strawberry-graphql-django[debug-toolbar]>=0.82.0",
44+
"poethepoet>=0.42.1",
4545
"bump-my-version>=1.2.7",
4646
]
4747

0 commit comments

Comments
 (0)