1from .ast import ( 2 Node, 3 DefinitionNode, 4 ExecutableDefinitionNode, 5 SchemaExtensionNode, 6 SelectionNode, 7 TypeDefinitionNode, 8 TypeExtensionNode, 9 TypeNode, 10 TypeSystemDefinitionNode, 11 ValueNode, 12) 13 14__all__ = [ 15 "is_definition_node", 16 "is_executable_definition_node", 17 "is_selection_node", 18 "is_value_node", 19 "is_type_node", 20 "is_type_system_definition_node", 21 "is_type_definition_node", 22 "is_type_system_extension_node", 23 "is_type_extension_node", 24] 25 26 27def is_definition_node(node: Node) -> bool: 28 """Check whether the given node represents a definition.""" 29 return isinstance(node, DefinitionNode) 30 31 32def is_executable_definition_node(node: Node) -> bool: 33 """Check whether the given node represents an executable definition.""" 34 return isinstance(node, ExecutableDefinitionNode) 35 36 37def is_selection_node(node: Node) -> bool: 38 """Check whether the given node represents a selection.""" 39 return isinstance(node, SelectionNode) 40 41 42def is_value_node(node: Node) -> bool: 43 """Check whether the given node represents a value.""" 44 return isinstance(node, ValueNode) 45 46 47def is_type_node(node: Node) -> bool: 48 """Check whether the given node represents a type.""" 49 return isinstance(node, TypeNode) 50 51 52def is_type_system_definition_node(node: Node) -> bool: 53 """Check whether the given node represents a type system definition.""" 54 return isinstance(node, TypeSystemDefinitionNode) 55 56 57def is_type_definition_node(node: Node) -> bool: 58 """Check whether the given node represents a type definition.""" 59 return isinstance(node, TypeDefinitionNode) 60 61 62def is_type_system_extension_node(node: Node) -> bool: 63 """Check whether the given node represents a type system extension.""" 64 return isinstance(node, (SchemaExtensionNode, TypeExtensionNode)) 65 66 67def is_type_extension_node(node: Node) -> bool: 68 """Check whether the given node represents a type extension.""" 69 return isinstance(node, TypeExtensionNode) 70