website/src/docs/hotchocolate/v16/api-reference/language.md
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.
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)"]
Every node in the syntax tree implements ISyntaxNode.
The
ToStringmethod of a syntax node prints the corresponding GraphQL syntax.
The interface defines the NodeKind of the node.
Node Kinds:
| Name | Description (Spec Link) | Context | Example |
|---|---|---|---|
| Name | All names, e.g., Field, Argument | Both | foo |
| NamedType | Reference to a type | Both | Foo |
| ListType | Definition of a list | Both | [Foo] |
| NonNullType | Definition of a non-null type | Both | Foo! |
| Argument | An argument with a Name and Value | Both | foo: "bar" |
| Directive | A directive | Query | @foo |
| Document | A complete file or request | Query (out) | |
| OperationDefinition | A query, mutation, or subscription operation | Query (out) | query Foo {} |
| VariableDefinition | Variables defined by an operation | Query (out) | ($foo: String) |
| Variable | A variable | Query (out) | $foo |
| SelectionSet | A set of Field, FragmentSpread, or InlineFragment selections | Query (out) | {foo bar} |
| Field | A field in a selection set | Query (out) | foo |
| FragmentSpread | A spread of a FragmentDefinition | Query (out) | ...f1 |
| InlineFragment | An inline fragment | Query (out) | ... on Foo { bar} |
| FragmentDefinition | A fragment definition | Query (out) | fragment f1 on Foo {} |
| IntValue | An int value | Query (in) | 1 |
| StringValue | A string value | Query (in) | "bar" |
| BooleanValue | A boolean value | Query (in) | true |
| NullValue | A null value | Query (in) | null |
| EnumValue | An enum value | Query (in) | FOO |
| FloatValue | A float value | Query (in) | 0.2 |
| ListValue | A list value | Query (in) | ["string"] |
| ObjectValue | An object value | Query (in) | {foo: "bar" } |
| ObjectField | A field of an input object type | Query (in) | foo: "bar" |
| SchemaDefinition | Schema definition | Schema | schema {} |
| OperationTypeDefinition | Root operation type definition | Schema | query:FooQuery |
| ScalarTypeDefinition | Scalar definition | Schema | scalar JSON |
| ObjectTypeDefinition | Object type definition | Schema | type Foo{} |
| FieldDefinition | Field definition | Schema | bar:String |
| InputValueDefinition | Input value definition | Schema | x: Float |
| InterfaceTypeDefinition | Interface definition | Schema | interface NamedEntity {} |
| UnionTypeDefinition | Union definition | Schema | union Ex = Foo | Bar |
| EnumTypeDefinition | Enum definition | Schema | enum Foo {BAR} |
| EnumValueDefinition | Enum value definition | Schema | BAR |
| InputObjectTypeDefinition | Input type definition | Schema | input FooInput {} |
| SchemaExtension | Schema extension | Schema | extend schema {} |
| ScalarTypeExtension | Scalar extension | Schema | extend scalar Foo @bar |
| ObjectTypeExtension | Object type extension | Schema | extend type Foo { name} |
| InterfaceTypeExtension | Interface type extension | Schema | extend interface NamedEntity {} |
| UnionTypeExtension | Union type extension | Schema | extend union Ex = Foo{} |
| EnumTypeExtension | Enum type extension | Schema | extend enum foo{} |
| InputObjectTypeExtension | Input type extension | Schema | input foo {} |
| DirectiveDefinition | Directive definition | Schema | directive @foo on |