Language

Learn about the Hot Chocolate v16 GraphQL Abstract Syntax Tree (AST) and syntax node types.

Abstract Syntax Tree (AST)

Hot Chocolate parses every incoming GraphQL request into an abstract syntax tree (AST). Each node in this tree represents a part of the incoming GraphQL query. The type system (ObjectType, InputType, etc.) configures the schema, and the AST represents parsed queries and schema documents.

GraphQL
query Users {
userName
address {
street
nr
}
}
graph TD;
    OperationDefinitionNode   -->  s1["SelectionSetNode"]
    s1["SelectionSetNode"]  --> id5["FieldNode (userName)"]
    s1["SelectionSetNode"]  --> id1["FieldNode (address)"]
    id1["FieldNode (address)"] -->  s2["SelectionSetNode"]
    s2["SelectionSetNode"]  -->   id3["FieldNode (street)"]
    s2["SelectionSetNode"]  -->   id4["FieldNode (nr)"]

Syntax Node

Every node in the syntax tree implements ISyntaxNode.

The ToString method of a syntax node prints the corresponding GraphQL syntax.

The interface defines the NodeKind of the node.

Node Kinds:

NameDescription (Spec Link)ContextExample
NameAll names, e.g., Field, ArgumentBothfoo
NamedTypeReference to a typeBothFoo
ListTypeDefinition of a listBoth[Foo]
NonNullTypeDefinition of a non-null typeBothFoo!
ArgumentAn argument with a Name and ValueBothfoo: "bar"
DirectiveA directiveQuery@foo
DocumentA complete file or requestQuery (out)
OperationDefinitionA query, mutation, or subscription operationQuery (out)query Foo {}
VariableDefinitionVariables defined by an operationQuery (out)($foo: String)
VariableA variableQuery (out)$foo
SelectionSetA set of Field, FragmentSpread, or InlineFragment selectionsQuery (out){foo bar}
FieldA field in a selection setQuery (out)foo
FragmentSpreadA spread of a FragmentDefinitionQuery (out)...f1
InlineFragmentAn inline fragmentQuery (out)... on Foo { bar}
FragmentDefinitionA fragment definitionQuery (out)fragment f1 on Foo {}
IntValueAn int valueQuery (in)1
StringValueA string valueQuery (in)"bar"
BooleanValueA boolean valueQuery (in)true
NullValueA null valueQuery (in)null
EnumValueAn enum valueQuery (in)FOO
FloatValueA float valueQuery (in)0.2
ListValueA list valueQuery (in)["string"]
ObjectValueAn object valueQuery (in){foo: "bar" }
ObjectFieldA field of an input object typeQuery (in)foo: "bar"
SchemaDefinitionSchema definitionSchemaschema {}
OperationTypeDefinitionRoot operation type definitionSchemaquery:FooQuery
ScalarTypeDefinitionScalar definitionSchemascalar JSON
ObjectTypeDefinitionObject type definitionSchematype Foo{}
FieldDefinitionField definitionSchemabar:String
InputValueDefinitionInput value definitionSchemax: Float
InterfaceTypeDefinitionInterface definitionSchemainterface NamedEntity {}
UnionTypeDefinitionUnion definitionSchemaunion Ex = Foo | Bar
EnumTypeDefinitionEnum definitionSchemaenum Foo {BAR}
EnumValueDefinitionEnum value definitionSchemaBAR
InputObjectTypeDefinitionInput type definitionSchemainput FooInput {}
SchemaExtensionSchema extensionSchemaextend schema {}
ScalarTypeExtensionScalar extensionSchemaextend scalar Foo @bar
ObjectTypeExtensionObject type extensionSchemaextend type Foo { name}
InterfaceTypeExtensionInterface type extensionSchemaextend interface NamedEntity {}
UnionTypeExtensionUnion type extensionSchemaextend union Ex = Foo{}
EnumTypeExtensionEnum type extensionSchemaextend enum foo{}
InputObjectTypeExtensionInput type extensionSchemainput foo {}
DirectiveDefinitionDirective definitionSchemadirective @foo on

Next Steps

Last updated on April 13, 2026 by Michael Staib