Coverage for src/lexigram/graphql/web/contributor.py: 92%
12 statements
« prev ^ index » next coverage.py v7.15.4, created at 2026-08-25 04:37 +0800
« prev ^ index » next coverage.py v7.15.4, created at 2026-08-25 04:37 +0800
1"""GraphQL web contributor for controller and middleware discovery."""
3from __future__ import annotations
5from typing import Any
8class GraphQLWebContributor:
9 """Web contributor that registers GraphQL HTTP controller.
11 This contributor exposes the GraphQL HTTP endpoint controller to the
12 web provider via entry-point discovery. WebSocket subscriptions are
13 handled separately by GraphQLIntegration.
15 Example:
16 Registered via entry-point in pyproject.toml::
18 [project.entry-points."lexigram.web.contributors"]
19 graphql = "lexigram.graphql.web.contributor:GraphQLWebContributor"
20 """
22 @property
23 def contributor_id(self) -> str:
24 """Return unique contributor identifier.
26 Returns:
27 The string "graphql" as the contributor identifier.
28 """
29 return "graphql"
31 def get_controllers(self) -> list[type[Any]]:
32 """Return GraphQL HTTP controller class.
34 Returns:
35 List containing GraphQLController class.
36 """
37 from lexigram.graphql.controllers.graphql import GraphQLController
39 return [GraphQLController]
41 def get_middleware(self) -> list[type[Any]]:
42 """Return middleware classes contributed by GraphQL package.
44 Currently GraphQL does not contribute any middleware.
46 Returns:
47 Empty list.
48 """
49 return []
51 async def mount_to_app(self, app: Any, container: object) -> None:
52 """No-op mount hook for GraphQL contributor.
54 GraphQL exposes routes via controller rather than app mount.
55 WebSocket subscriptions are handled separately by GraphQLIntegration.
57 Args:
58 app: The ASGI application (unused).
59 container: The DI container (unused).
60 """