Skip to content

Commit 648031c

Browse files
ImTotemclaude
andcommitted
fix(graphql): inherit BaseContext for GqlContext
Strawberry FastAPI requires custom context to extend BaseContext. Replace dataclass with explicit __init__ + BaseContext inheritance. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 198ee24 commit 648031c

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

src/bcsd_api/graphql/context.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
from dataclasses import dataclass
2-
31
from fastapi import Depends, Request
42
from sqlalchemy import Connection
3+
from strawberry.fastapi import BaseContext
54

65
from bcsd_api.auth import token as jwt_token
76
from bcsd_api.config import Settings
@@ -16,12 +15,12 @@
1615
from bcsd_api.shorten.pg_repository import PgLinkRepository
1716

1817

19-
@dataclass
20-
class GqlContext:
21-
conn: Connection
22-
member_repo: PgMemberRepository
23-
link_repo: PgLinkRepository
24-
user: dict | None
18+
class GqlContext(BaseContext):
19+
def __init__(self, conn, member_repo, link_repo, user):
20+
self.conn = conn
21+
self.member_repo = member_repo
22+
self.link_repo = link_repo
23+
self.user = user
2524

2625

2726
def _try_auth(request: Request, settings: Settings) -> dict | None:

0 commit comments

Comments
 (0)