Debian Codegraph @

src/graphql/language/ast.py

raw
1 from copy import copy, deepcopy
2 from enum import Enum
3 from typing import Any, Dict, List, Tuple, Optional, Union
4
5 from .source import Source
6 from .token_kind import TokenKind
7 from ..pyutils import camel_to_snake
8
9 __all__ = [
10 "Location",
11 "Token",
12 "Node",
13 "NameNode",
14 "DocumentNode",
15 "DefinitionNode",
16 "ExecutableDefinitionNode",
17 "OperationDefinitionNode",
18 "VariableDefinitionNode",
19 "SelectionSetNode",
20 "SelectionNode",
21 "FieldNode",
22 "ArgumentNode",
23 "ConstArgumentNode",
24 "FragmentSpreadNode",
25 "InlineFragmentNode",
26 "FragmentDefinitionNode",
27 "ValueNode",
28 "ConstValueNode",
29 "VariableNode",
30 "IntValueNode",
31 "FloatValueNode",
32 "StringValueNode",
33 "BooleanValueNode",
34 "NullValueNode",
35 "EnumValueNode",
36 "ListValueNode",
37 "ConstListValueNode",
38 "ObjectValueNode",
39 "ConstObjectValueNode",
40 "ObjectFieldNode",
41 "ConstObjectFieldNode",
42 "DirectiveNode",
43 "ConstDirectiveNode",
44 "TypeNode",
45 "NamedTypeNode",
46 "ListTypeNode",
47 "NonNullTypeNode",
48 "TypeSystemDefinitionNode",
49 "SchemaDefinitionNode",
50 "OperationType",
51 "OperationTypeDefinitionNode",
52 "TypeDefinitionNode",
53 "ScalarTypeDefinitionNode",
54 "ObjectTypeDefinitionNode",
55 "FieldDefinitionNode",
56 "InputValueDefinitionNode",
57 "InterfaceTypeDefinitionNode",
58 "UnionTypeDefinitionNode",
59 "EnumTypeDefinitionNode",
60 "EnumValueDefinitionNode",
61 "InputObjectTypeDefinitionNode",
62 "DirectiveDefinitionNode",
63 "SchemaExtensionNode",
64 "TypeExtensionNode",
65 "TypeSystemExtensionNode",
66 "ScalarTypeExtensionNode",
67 "ObjectTypeExtensionNode",
68 "InterfaceTypeExtensionNode",
69 "UnionTypeExtensionNode",
70 "EnumTypeExtensionNode",
71 "InputObjectTypeExtensionNode",
72 "DirectiveExtensionNode",
73 "SchemaCoordinateNode",
74 "TypeCoordinateNode",
75 "MemberCoordinateNode",
76 "ArgumentCoordinateNode",
77 "DirectiveCoordinateNode",
78 "DirectiveArgumentCoordinateNode",
79 "QUERY_DOCUMENT_KEYS",
80 ]
81
82
83 class Token:
84 """AST Token
85
86 Represents a range of characters represented by a lexical token within a Source.
87 """
88
89 __slots__ = "kind", "start", "end", "line", "column", "prev", "next", "value"
90
91 kind: TokenKind # the kind of token
92 start: int # the character offset at which this Node begins
93 end: int # the character offset at which this Node ends
94 line: int # the 1-indexed line number on which this Token appears
95 column: int # the 1-indexed column number at which this Token begins
96 # for non-punctuation tokens, represents the interpreted value of the token:
97 value: Optional[str]
98 # Tokens exist as nodes in a double-linked-list amongst all tokens including
99 # ignored tokens. <SOF> is always the first node and <EOF> the last.
100 prev: Optional["Token"]
101 next: Optional["Token"]
102
103 def __init__(
104 self,
105 kind: TokenKind,
106 start: int,
107 end: int,
108 line: int,
109 column: int,
110 value: Optional[str] = None,
111 ) -> None:
112 self.kind = kind
113 self.start, self.end = start, end
114 self.line, self.column = line, column
115 self.value = value
116 self.prev = self.next = None
117
118 def __str__(self) -> str:
119 return self.desc
120
121 def __repr__(self) -> str:
122 """Print a simplified form when appearing in repr() or inspect()."""
123 return f"<Token {self.desc} {self.line}:{self.column}>"
124
125 def __inspect__(self) -> str:
126 return repr(self)
127
128 def __eq__(self, other: Any) -> bool:
129 if isinstance(other, Token):
130 return (
131 self.kind == other.kind
132 and self.start == other.start
133 and self.end == other.end
134 and self.line == other.line
135 and self.column == other.column
136 and self.value == other.value
137 )
138 elif isinstance(other, str):
139 return other == self.desc
140 return False
141
142 def __hash__(self) -> int:
143 return hash(
144 (self.kind, self.start, self.end, self.line, self.column, self.value)
145 )
146
147 def __copy__(self) -> "Token":
148 """Create a shallow copy of the token"""
149 token = self.__class__(
150 self.kind,
151 self.start,
152 self.end,
153 self.line,
154 self.column,
155 self.value,
156 )
157 token.prev = self.prev
158 return token
159
160 def __deepcopy__(self, memo: Dict) -> "Token":
161 """Allow only shallow copies to avoid recursion."""
162 return copy(self)
163
164 def __getstate__(self) -> Dict[str, Any]:
165 """Remove the links when pickling.
166
167 Keeping the links would make pickling a schema too expensive.
168 """
169 return {
170 key: getattr(self, key)
171 for key in self.__slots__
172 if key not in {"prev", "next"}
173 }
174
175 def __setstate__(self, state: Dict[str, Any]) -> None:
176 """Reset the links when un-pickling."""
177 for key, value in state.items():
178 setattr(self, key, value)
179 self.prev = self.next = None
180
181 @property
182 def desc(self) -> str:
183 """A helper property to describe a token as a string for debugging"""
184 kind, value = self.kind.value, self.value
185 return f"{kind} {value!r}" if value else kind
186
187
188 class Location:
189 """AST Location
190
191 Contains a range of UTF-8 character offsets and token references that identify the
192 region of the source from which the AST derived.
193 """
194
195 __slots__ = (
196 "start",
197 "end",
198 "start_token",
199 "end_token",
200 "source",
201 )
202
203 start: int # character offset at which this Node begins
204 end: int # character offset at which this Node ends
205 start_token: Token # Token at which this Node begins
206 end_token: Token # Token at which this Node ends.
207 source: Source # Source document the AST represents
208
209 def __init__(self, start_token: Token, end_token: Token, source: Source) -> None:
210 self.start = start_token.start
211 self.end = end_token.end
212 self.start_token = start_token
213 self.end_token = end_token
214 self.source = source
215
216 def __str__(self) -> str:
217 return f"{self.start}:{self.end}"
218
219 def __repr__(self) -> str:
220 """Print a simplified form when appearing in repr() or inspect()."""
221 return f"<Location {self.start}:{self.end}>"
222
223 def __inspect__(self) -> str:
224 return repr(self)
225
226 def __eq__(self, other: Any) -> bool:
227 if isinstance(other, Location):
228 return self.start == other.start and self.end == other.end
229 elif isinstance(other, (list, tuple)) and len(other) == 2:
230 return self.start == other[0] and self.end == other[1]
231 return False
232
233 def __ne__(self, other: Any) -> bool:
234 return not self == other
235
236 def __hash__(self) -> int:
237 return hash((self.start, self.end))
238
239
240 class OperationType(Enum):
241
242 QUERY = "query"
243 MUTATION = "mutation"
244 SUBSCRIPTION = "subscription"
245
246
247 # Default map from node kinds to their node attributes (internal)
248 QUERY_DOCUMENT_KEYS: Dict[str, Tuple[str, ...]] = {
249 "name": (),
250 "document": ("definitions",),
251 "operation_definition": (
252 "description",
253 "name",
254 "variable_definitions",
255 "directives",
256 "selection_set",
257 ),
258 "variable_definition": (
259 "description",
260 "variable",
261 "type",
262 "default_value",
263 "directives",
264 ),
265 "variable": ("name",),
266 "selection_set": ("selections",),
267 "field": ("alias", "name", "arguments", "directives", "selection_set"),
268 "argument": ("name", "value"),
269 "fragment_spread": ("name", "directives"),
270 "inline_fragment": ("type_condition", "directives", "selection_set"),
271 "fragment_definition": (
272 "description",
273 # Note: fragment variable definitions are deprecated and will be removed in v3.3
274 "name",
275 "variable_definitions",
276 "type_condition",
277 "directives",
278 "selection_set",
279 ),
280 "list_value": ("values",),
281 "object_value": ("fields",),
282 "object_field": ("name", "value"),
283 "directive": ("name", "arguments"),
284 "named_type": ("name",),
285 "list_type": ("type",),
286 "non_null_type": ("type",),
287 "schema_definition": ("description", "directives", "operation_types"),
288 "operation_type_definition": ("type",),
289 "scalar_type_definition": ("description", "name", "directives"),
290 "object_type_definition": (
291 "description",
292 "name",
293 "interfaces",
294 "directives",
295 "fields",
296 ),
297 "field_definition": ("description", "name", "arguments", "type", "directives"),
298 "input_value_definition": (
299 "description",
300 "name",
301 "type",
302 "default_value",
303 "directives",
304 ),
305 "interface_type_definition": (
306 "description",
307 "name",
308 "interfaces",
309 "directives",
310 "fields",
311 ),
312 "union_type_definition": ("description", "name", "directives", "types"),
313 "enum_type_definition": ("description", "name", "directives", "values"),
314 "enum_value_definition": ("description", "name", "directives"),
315 "input_object_type_definition": ("description", "name", "directives", "fields"),
316 "directive_definition": (
317 "description",
318 "name",
319 "arguments",
320 "directives",
321 "locations",
322 ),
323 "schema_extension": ("directives", "operation_types"),
324 "directive_extension": ("name", "directives"),
325 "scalar_type_extension": ("name", "directives"),
326 "object_type_extension": ("name", "interfaces", "directives", "fields"),
327 "interface_type_extension": ("name", "interfaces", "directives", "fields"),
328 "union_type_extension": ("name", "directives", "types"),
329 "enum_type_extension": ("name", "directives", "values"),
330 "input_object_type_extension": ("name", "directives", "fields"),
331 "type_coordinate": ("name",),
332 "member_coordinate": ("name", "member_name"),
333 "argument_coordinate": ("name", "field_name", "argument_name"),
334 "directive_coordinate": ("name",),
335 "directive_argument_coordinate": ("name", "argument_name"),
336 }
337
338
339 # Base AST Node
340
341
342 class Node:
343 """AST nodes"""
344
345 # allow custom attributes and weak references (not used internally)
346 __slots__ = "__dict__", "__weakref__", "loc", "_hash"
347
348 loc: Optional[Location]
349
350 kind: str = "ast" # the kind of the node as a snake_case string
351 keys: Tuple[str, ...] = ("loc",) # the names of the attributes of this node
352
353 def __init__(self, **kwargs: Any) -> None:
354 """Initialize the node with the given keyword arguments."""
355 for key in self.keys:
356 value = kwargs.get(key)
357 if isinstance(value, list):
358 value = tuple(value)
359 setattr(self, key, value)
360
361 def __repr__(self) -> str:
362 """Get a simple representation of the node."""
363 name, loc = self.__class__.__name__, getattr(self, "loc", None)
364 return f"{name} at {loc}" if loc else name
365
366 def __eq__(self, other: Any) -> bool:
367 """Test whether two nodes are equal (recursively)."""
368 return (
369 isinstance(other, Node)
370 and self.__class__ == other.__class__
371 and all(getattr(self, key) == getattr(other, key) for key in self.keys)
372 )
373
374 def __hash__(self) -> int:
375 """Get a cached hash value for the node."""
376 # Caching the hash values improves the performance of AST validators
377 hashed = getattr(self, "_hash", None)
378 if hashed is None:
379 self._hash = id(self) # avoid recursion
380 hashed = hash(tuple(getattr(self, key) for key in self.keys))
381 self._hash = hashed
382 return hashed
383
384 def __setattr__(self, key: str, value: Any) -> None:
385 # reset cashed hash value if attributes are changed
386 if hasattr(self, "_hash") and key in self.keys:
387 del self._hash
388 super().__setattr__(key, value)
389
390 def __copy__(self) -> "Node":
391 """Create a shallow copy of the node."""
392 return self.__class__(**{key: getattr(self, key) for key in self.keys})
393
394 def __deepcopy__(self, memo: Dict) -> "Node":
395 """Create a deep copy of the node"""
396 # noinspection PyArgumentList
397 return self.__class__(
398 **{key: deepcopy(getattr(self, key), memo) for key in self.keys}
399 )
400
401 def __init_subclass__(cls) -> None:
402 super().__init_subclass__()
403 name = cls.__name__
404 try:
405 name = name.removeprefix("Const").removesuffix("Node")
406 except AttributeError: # pragma: no cover (Python < 3.9)
407 if name.startswith("Const"):
408 name = name[5:]
409 if name.endswith("Node"):
410 name = name[:-4]
411 cls.kind = camel_to_snake(name)
412 keys: List[str] = []
413 for base in cls.__bases__:
414 # noinspection PyUnresolvedReferences
415 keys.extend(base.keys) # type: ignore
416 keys.extend(cls.__slots__)
417 cls.keys = tuple(keys)
418
419 def to_dict(self, locations: bool = False) -> Dict:
420 from ..utilities import ast_to_dict
421
422 return ast_to_dict(self, locations)
423
424
425 # Name
426
427
428 class NameNode(Node):
429 __slots__ = ("value",)
430
431 value: str
432
433
434 # Document
435
436
437 class DocumentNode(Node):
438 __slots__ = ("definitions",)
439
440 definitions: Tuple["DefinitionNode", ...]
441 # The number of tokens in the parsed document. Set by the parser per instance
442 # and deliberately kept out of ``__slots__`` (and therefore out of ``keys``) so
443 # that it is not treated as a traversable attribute, the equivalent of the
444 # non-enumerable ``tokenCount`` property in graphql-js.
445 token_count: int = 0
446
447
448 class DefinitionNode(Node):
449 __slots__ = ()
450
451
452 class ExecutableDefinitionNode(DefinitionNode):
453 __slots__ = (
454 "description",
455 "name",
456 "directives",
457 "variable_definitions",
458 "selection_set",
459 )
460
461 description: Optional["StringValueNode"]
462 name: Optional[NameNode]
463 directives: Tuple["DirectiveNode", ...]
464 variable_definitions: Tuple["VariableDefinitionNode", ...]
465 selection_set: "SelectionSetNode"
466
467
468 class OperationDefinitionNode(ExecutableDefinitionNode):
469 __slots__ = ("operation",)
470
471 operation: OperationType
472
473
474 class VariableDefinitionNode(Node):
475 __slots__ = "description", "variable", "type", "default_value", "directives"
476
477 description: Optional["StringValueNode"]
478 variable: "VariableNode"
479 type: "TypeNode"
480 default_value: Optional["ConstValueNode"]
481 directives: Tuple["ConstDirectiveNode", ...]
482
483
484 class SelectionSetNode(Node):
485 __slots__ = ("selections",)
486
487 selections: Tuple["SelectionNode", ...]
488
489
490 class SelectionNode(Node):
491 __slots__ = ("directives",)
492
493 directives: Tuple["DirectiveNode", ...]
494
495
496 class FieldNode(SelectionNode):
497 __slots__ = "alias", "name", "arguments", "selection_set"
498
499 alias: Optional[NameNode]
500 name: NameNode
501 arguments: Tuple["ArgumentNode", ...]
502 selection_set: Optional[SelectionSetNode]
503
504
505 class ArgumentNode(Node):
506 __slots__ = "name", "value"
507
508 name: NameNode
509 value: "ValueNode"
510
511
512 class ConstArgumentNode(ArgumentNode):
513
514 value: "ConstValueNode"
515
516
517 # Fragments
518
519
520 class FragmentSpreadNode(SelectionNode):
521 __slots__ = ("name",)
522
523 name: NameNode
524
525
526 class InlineFragmentNode(SelectionNode):
527 __slots__ = "type_condition", "selection_set"
528
529 type_condition: "NamedTypeNode"
530 selection_set: SelectionSetNode
531
532
533 class FragmentDefinitionNode(ExecutableDefinitionNode):
534 __slots__ = ("type_condition",)
535
536 name: NameNode
537 type_condition: "NamedTypeNode"
538
539
540 # Values
541
542
543 class ValueNode(Node):
544 __slots__ = ()
545
546
547 class VariableNode(ValueNode):
548 __slots__ = ("name",)
549
550 name: NameNode
551
552
553 class IntValueNode(ValueNode):
554 __slots__ = ("value",)
555
556 value: str
557
558
559 class FloatValueNode(ValueNode):
560 __slots__ = ("value",)
561
562 value: str
563
564
565 class StringValueNode(ValueNode):
566 __slots__ = "value", "block"
567
568 value: str
569 block: Optional[bool]
570
571
572 class BooleanValueNode(ValueNode):
573 __slots__ = ("value",)
574
575 value: bool
576
577
578 class NullValueNode(ValueNode):
579 __slots__ = ()
580
581
582 class EnumValueNode(ValueNode):
583 __slots__ = ("value",)
584
585 value: str
586
587
588 class ListValueNode(ValueNode):
589 __slots__ = ("values",)
590
591 values: Tuple[ValueNode, ...]
592
593
594 class ConstListValueNode(ListValueNode):
595
596 values: Tuple["ConstValueNode", ...]
597
598
599 class ObjectValueNode(ValueNode):
600 __slots__ = ("fields",)
601
602 fields: Tuple["ObjectFieldNode", ...]
603
604
605 class ConstObjectValueNode(ObjectValueNode):
606
607 fields: Tuple["ConstObjectFieldNode", ...]
608
609
610 class ObjectFieldNode(Node):
611 __slots__ = "name", "value"
612
613 name: NameNode
614 value: ValueNode
615
616
617 class ConstObjectFieldNode(ObjectFieldNode):
618
619 value: "ConstValueNode"
620
621
622 ConstValueNode = Union[
623 IntValueNode,
624 FloatValueNode,
625 StringValueNode,
626 BooleanValueNode,
627 NullValueNode,
628 EnumValueNode,
629 ConstListValueNode,
630 ConstObjectValueNode,
631 ]
632
633
634 # Directives
635
636
637 class DirectiveNode(Node):
638 __slots__ = "name", "arguments"
639
640 name: NameNode
641 arguments: Tuple[ArgumentNode, ...]
642
643
644 class ConstDirectiveNode(DirectiveNode):
645
646 arguments: Tuple[ConstArgumentNode, ...]
647
648
649 # Type Reference
650
651
652 class TypeNode(Node):
653 __slots__ = ()
654
655
656 class NamedTypeNode(TypeNode):
657 __slots__ = ("name",)
658
659 name: NameNode
660
661
662 class ListTypeNode(TypeNode):
663 __slots__ = ("type",)
664
665 type: TypeNode
666
667
668 class NonNullTypeNode(TypeNode):
669 __slots__ = ("type",)
670
671 type: Union[NamedTypeNode, ListTypeNode]
672
673
674 # Type System Definition
675
676
677 class TypeSystemDefinitionNode(DefinitionNode):
678 __slots__ = ()
679
680
681 class SchemaDefinitionNode(TypeSystemDefinitionNode):
682 __slots__ = "description", "directives", "operation_types"
683
684 description: Optional[StringValueNode]
685 directives: Tuple[ConstDirectiveNode, ...]
686 operation_types: Tuple["OperationTypeDefinitionNode", ...]
687
688
689 class OperationTypeDefinitionNode(Node):
690 __slots__ = "operation", "type"
691
692 operation: OperationType
693 type: NamedTypeNode
694
695
696 # Type Definition
697
698
699 class TypeDefinitionNode(TypeSystemDefinitionNode):
700 __slots__ = "description", "name", "directives"
701
702 description: Optional[StringValueNode]
703 name: NameNode
704 directives: Tuple[DirectiveNode, ...]
705
706
707 class ScalarTypeDefinitionNode(TypeDefinitionNode):
708 __slots__ = ()
709
710 directives: Tuple[ConstDirectiveNode, ...]
711
712
713 class ObjectTypeDefinitionNode(TypeDefinitionNode):
714 __slots__ = "interfaces", "fields"
715
716 interfaces: Tuple[NamedTypeNode, ...]
717 directives: Tuple[ConstDirectiveNode, ...]
718 fields: Tuple["FieldDefinitionNode", ...]
719
720
721 class FieldDefinitionNode(DefinitionNode):
722 __slots__ = "description", "name", "directives", "arguments", "type"
723
724 description: Optional[StringValueNode]
725 name: NameNode
726 directives: Tuple[ConstDirectiveNode, ...]
727 arguments: Tuple["InputValueDefinitionNode", ...]
728 type: TypeNode
729
730
731 class InputValueDefinitionNode(DefinitionNode):
732 __slots__ = "description", "name", "directives", "type", "default_value"
733
734 description: Optional[StringValueNode]
735 name: NameNode
736 directives: Tuple[ConstDirectiveNode, ...]
737 type: TypeNode
738 default_value: Optional[ConstValueNode]
739
740
741 class InterfaceTypeDefinitionNode(TypeDefinitionNode):
742 __slots__ = "fields", "interfaces"
743
744 fields: Tuple["FieldDefinitionNode", ...]
745 directives: Tuple[ConstDirectiveNode, ...]
746 interfaces: Tuple[NamedTypeNode, ...]
747
748
749 class UnionTypeDefinitionNode(TypeDefinitionNode):
750 __slots__ = ("types",)
751
752 directives: Tuple[ConstDirectiveNode, ...]
753 types: Tuple[NamedTypeNode, ...]
754
755
756 class EnumTypeDefinitionNode(TypeDefinitionNode):
757 __slots__ = ("values",)
758
759 directives: Tuple[ConstDirectiveNode, ...]
760 values: Tuple["EnumValueDefinitionNode", ...]
761
762
763 class EnumValueDefinitionNode(DefinitionNode):
764 __slots__ = "description", "name", "directives"
765
766 description: Optional[StringValueNode]
767 name: NameNode
768 directives: Tuple[ConstDirectiveNode, ...]
769
770
771 class InputObjectTypeDefinitionNode(TypeDefinitionNode):
772 __slots__ = ("fields",)
773
774 directives: Tuple[ConstDirectiveNode, ...]
775 fields: Tuple[InputValueDefinitionNode, ...]
776
777
778 # Directive Definitions
779
780
781 class DirectiveDefinitionNode(TypeSystemDefinitionNode):
782 __slots__ = (
783 "description",
784 "name",
785 "arguments",
786 "directives",
787 "repeatable",
788 "locations",
789 )
790
791 description: Optional[StringValueNode]
792 name: NameNode
793 arguments: Tuple[InputValueDefinitionNode, ...]
794 directives: Tuple[ConstDirectiveNode, ...]
795 repeatable: bool
796 locations: Tuple[NameNode, ...]
797
798
799 # Type System Extensions
800
801
802 class SchemaExtensionNode(Node):
803 __slots__ = "directives", "operation_types"
804
805 directives: Tuple[ConstDirectiveNode, ...]
806 operation_types: Tuple[OperationTypeDefinitionNode, ...]
807
808
809 class DirectiveExtensionNode(Node):
810 __slots__ = "name", "directives"
811
812 name: NameNode
813 directives: Tuple[ConstDirectiveNode, ...]
814
815
816 # Type Extensions
817
818
819 class TypeExtensionNode(TypeSystemDefinitionNode):
820 __slots__ = "name", "directives"
821
822 name: NameNode
823 directives: Tuple[ConstDirectiveNode, ...]
824
825
826 TypeSystemExtensionNode = Union[
827 SchemaExtensionNode, TypeExtensionNode, DirectiveExtensionNode
828 ]
829
830
831 class ScalarTypeExtensionNode(TypeExtensionNode):
832 __slots__ = ()
833
834
835 class ObjectTypeExtensionNode(TypeExtensionNode):
836 __slots__ = "interfaces", "fields"
837
838 interfaces: Tuple[NamedTypeNode, ...]
839 fields: Tuple[FieldDefinitionNode, ...]
840
841
842 class InterfaceTypeExtensionNode(TypeExtensionNode):
843 __slots__ = "interfaces", "fields"
844
845 interfaces: Tuple[NamedTypeNode, ...]
846 fields: Tuple[FieldDefinitionNode, ...]
847
848
849 class UnionTypeExtensionNode(TypeExtensionNode):
850 __slots__ = ("types",)
851
852 types: Tuple[NamedTypeNode, ...]
853
854
855 class EnumTypeExtensionNode(TypeExtensionNode):
856 __slots__ = ("values",)
857
858 values: Tuple[EnumValueDefinitionNode, ...]
859
860
861 class InputObjectTypeExtensionNode(TypeExtensionNode):
862 __slots__ = ("fields",)
863
864 fields: Tuple[InputValueDefinitionNode, ...]
865
866
867 # Schema Coordinates
868
869
870 class TypeCoordinateNode(Node):
871 __slots__ = ("name",)
872
873 name: NameNode
874
875
876 class MemberCoordinateNode(Node):
877 __slots__ = "name", "member_name"
878
879 name: NameNode
880 member_name: NameNode
881
882
883 class ArgumentCoordinateNode(Node):
884 __slots__ = "name", "field_name", "argument_name"
885
886 name: NameNode
887 field_name: NameNode
888 argument_name: NameNode
889
890
891 class DirectiveCoordinateNode(Node):
892 __slots__ = ("name",)
893
894 name: NameNode
895
896
897 class DirectiveArgumentCoordinateNode(Node):
898 __slots__ = "name", "argument_name"
899
900 name: NameNode
901 argument_name: NameNode
902
903
904 SchemaCoordinateNode = Union[
905 TypeCoordinateNode,
906 MemberCoordinateNode,
907 ArgumentCoordinateNode,
908 DirectiveCoordinateNode,
909 DirectiveArgumentCoordinateNode,
910 ]