Coverage for src/lexigram/graphql/hooks.py: 100%
13 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"""Root hook payload surface for lexigram-graphql.
3Defines canonical payload dataclasses for GraphQL lifecycle hook points.
4Actual hook registration and invocation use the framework's string-keyed
5``HookRegistryProtocol`` action/filter APIs.
6"""
8from __future__ import annotations
10from dataclasses import dataclass
12__all__ = [
13 "GraphQLRequestReceivedHook",
14 "GraphQLResponsePreparedHook",
15 "GraphQLSchemaBuiltHook",
16]
19@dataclass(frozen=True, kw_only=True)
20class GraphQLSchemaBuiltHook:
21 """Payload fired after the GraphQL schema has been compiled and is ready."""
24@dataclass(frozen=True, kw_only=True)
25class GraphQLRequestReceivedHook:
26 """Payload fired when a GraphQL operation request is received.
28 Attributes:
29 operation_type: ``"query"``, ``"mutation"``, or ``"subscription"``.
30 operation_name: Named operation, if present in the document.
31 """
33 operation_type: str
34 operation_name: str | None = None
37@dataclass(frozen=True, kw_only=True)
38class GraphQLResponsePreparedHook:
39 """Payload fired after a GraphQL response has been assembled.
41 Attributes:
42 operation_type: ``"query"``, ``"mutation"``, or ``"subscription"``.
43 has_errors: ``True`` if the response contains any GraphQL errors.
44 """
46 operation_type: str
47 has_errors: bool