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

1"""Root hook payload surface for lexigram-graphql. 

2 

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""" 

7 

8from __future__ import annotations 

9 

10from dataclasses import dataclass 

11 

12__all__ = [ 

13 "GraphQLRequestReceivedHook", 

14 "GraphQLResponsePreparedHook", 

15 "GraphQLSchemaBuiltHook", 

16] 

17 

18 

19@dataclass(frozen=True, kw_only=True) 

20class GraphQLSchemaBuiltHook: 

21 """Payload fired after the GraphQL schema has been compiled and is ready.""" 

22 

23 

24@dataclass(frozen=True, kw_only=True) 

25class GraphQLRequestReceivedHook: 

26 """Payload fired when a GraphQL operation request is received. 

27 

28 Attributes: 

29 operation_type: ``"query"``, ``"mutation"``, or ``"subscription"``. 

30 operation_name: Named operation, if present in the document. 

31 """ 

32 

33 operation_type: str 

34 operation_name: str | None = None 

35 

36 

37@dataclass(frozen=True, kw_only=True) 

38class GraphQLResponsePreparedHook: 

39 """Payload fired after a GraphQL response has been assembled. 

40 

41 Attributes: 

42 operation_type: ``"query"``, ``"mutation"``, or ``"subscription"``. 

43 has_errors: ``True`` if the response contains any GraphQL errors. 

44 """ 

45 

46 operation_type: str 

47 has_errors: bool