package ast
Scala classes to represent the GraphQL AST (abstract syntax tree).
Though we call them “AST”, these types represent something closer to a concrete syntax tree, since they are close to the original parse and can hold information about source code location and comments.
The root of the AST is the Document type, so that would be the place to start understanding the AST. The AST closely follows the specification.
The GraphQL language includes an IDL (the type system definition) used to describe a GraphQL service’s type system. Tools may use this IDL to provide utilities such as client code generation or service boot‐strapping. The Scala types that represent the parsed nodes of the IDL constitute almost half of the Scala types in this package. Tools which only seek to provide GraphQL query execution may not need to parse the type system definition nodes.
- Grouped
- Alphabetic
- By Inheritance
- ast
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Type Members
- class AggregateSourceMapper extends SourceMapper
SourceMapper for potentially multiple GraphQL documents.
SourceMapper for potentially multiple GraphQL documents.
Sometimes it's necessary to compose a GraphQL document from multiple component documents; this class provides the corresponding
SourceMapper
to support that. - case class Argument(name: String, value: Value, comments: Vector[Comment] = Vector.empty, location: Option[AstLocation] = None) extends NameValue with Product with Serializable
- case class AstLocation(sourceId: String, index: Int, line: Int, column: Int) extends Product with Serializable
A location within a GraphQL source code string.
A location within a GraphQL source code string.
- sourceId
The ID of the source code.
- index
The offset of the location as characters from the start of the source code.
- line
The line number of the location within the source code.
- column
The column number of the location within the source code.
- sealed trait AstNode extends AnyRef
A node in the AST of a parsed GraphQL request document.
- case class BigDecimalValue(value: BigDecimal, comments: Vector[Comment] = Vector.empty, location: Option[AstLocation] = None) extends ScalarValue with Product with Serializable
- case class BigIntValue(value: BigInt, comments: Vector[Comment] = Vector.empty, location: Option[AstLocation] = None) extends ScalarValue with Product with Serializable
- case class BooleanValue(value: Boolean, comments: Vector[Comment] = Vector.empty, location: Option[AstLocation] = None) extends ScalarValue with Product with Serializable
- case class Comment(text: String, location: Option[AstLocation] = None) extends AstNode with Product with Serializable
- sealed trait ConditionalFragment extends AstNode
- class DefaultSourceMapper extends SourceMapper
sangria.ast.SourceMapper for a single GraphQL document.
- sealed trait Definition extends AstNode
A definition in a GraphQL document.
A definition in a GraphQL document.
A GraphQL document consists primarily of definitions, which are either executable or representative of a GraphQL type system. The executable definitions are operation and fragment definitions; those that represent a type system fall into definition or extension categories.
- case class Directive(name: String, arguments: Vector[Argument] = Vector.empty, comments: Vector[Comment] = Vector.empty, location: Option[AstLocation] = None) extends AstNode with WithArguments with Product with Serializable
- case class DirectiveDefinition(name: String, arguments: Vector[InputValueDefinition], locations: Vector[DirectiveLocation], description: Option[StringValue] = None, repeatable: Boolean = false, comments: Vector[Comment] = Vector.empty, location: Option[AstLocation] = None) extends TypeSystemDefinition with WithDescription with Product with Serializable
- case class DirectiveLocation(name: String, comments: Vector[Comment] = Vector.empty, location: Option[AstLocation] = None) extends SchemaAstNode with Product with Serializable
- case class Document(definitions: Vector[Definition], trailingComments: Vector[Comment] = Vector.empty, location: Option[AstLocation] = None, sourceMapper: Option[SourceMapper] = None) extends AstNode with WithTrailingComments with Product with Serializable
A complete GraphQL request operated on by a GraphQL service.
A complete GraphQL request operated on by a GraphQL service.
- definitions
The definitions, which primarily constitute the document.
- case class EnumTypeDefinition(name: String, values: Vector[EnumValueDefinition], directives: Vector[Directive] = Vector.empty, description: Option[StringValue] = None, comments: Vector[Comment] = Vector.empty, trailingComments: Vector[Comment] = Vector.empty, location: Option[AstLocation] = None) extends TypeDefinition with WithTrailingComments with WithDescription with Product with Serializable
- case class EnumTypeExtensionDefinition(name: String, values: Vector[EnumValueDefinition], directives: Vector[Directive] = Vector.empty, comments: Vector[Comment] = Vector.empty, trailingComments: Vector[Comment] = Vector.empty, location: Option[AstLocation] = None) extends TypeExtensionDefinition with WithTrailingComments with Product with Serializable
- case class EnumValue(value: String, comments: Vector[Comment] = Vector.empty, location: Option[AstLocation] = None) extends Value with Product with Serializable
- case class EnumValueDefinition(name: String, directives: Vector[Directive] = Vector.empty, description: Option[StringValue] = None, comments: Vector[Comment] = Vector.empty, location: Option[AstLocation] = None) extends SchemaAstNode with WithDirectives with WithDescription with Product with Serializable
- case class Field(alias: Option[String], name: String, arguments: Vector[Argument], directives: Vector[Directive], selections: Vector[Selection], comments: Vector[Comment] = Vector.empty, trailingComments: Vector[Comment] = Vector.empty, location: Option[AstLocation] = None) extends Selection with SelectionContainer with WithArguments with Product with Serializable
- case class FieldDefinition(name: String, fieldType: Type, arguments: Vector[InputValueDefinition], directives: Vector[Directive] = Vector.empty, description: Option[StringValue] = None, comments: Vector[Comment] = Vector.empty, location: Option[AstLocation] = None) extends SchemaAstNode with WithDirectives with WithDescription with Product with Serializable
- case class FloatValue(value: Double, comments: Vector[Comment] = Vector.empty, location: Option[AstLocation] = None) extends ScalarValue with Product with Serializable
- case class FragmentDefinition(name: String, typeCondition: NamedType, directives: Vector[Directive], selections: Vector[Selection], variables: Vector[VariableDefinition] = Vector.empty, comments: Vector[Comment] = Vector.empty, trailingComments: Vector[Comment] = Vector.empty, location: Option[AstLocation] = None) extends Definition with ConditionalFragment with WithDirectives with SelectionContainer with Product with Serializable
- case class FragmentSpread(name: String, directives: Vector[Directive], comments: Vector[Comment] = Vector.empty, location: Option[AstLocation] = None) extends Selection with Product with Serializable
- case class InlineFragment(typeCondition: Option[NamedType], directives: Vector[Directive], selections: Vector[Selection], comments: Vector[Comment] = Vector.empty, trailingComments: Vector[Comment] = Vector.empty, location: Option[AstLocation] = None) extends Selection with ConditionalFragment with SelectionContainer with Product with Serializable
- case class InputDocument(values: Vector[Value], trailingComments: Vector[Comment] = Vector.empty, location: Option[AstLocation] = None, sourceMapper: Option[SourceMapper] = None) extends AstNode with WithTrailingComments with Product with Serializable
- case class InputObjectTypeDefinition(name: String, fields: Vector[InputValueDefinition], directives: Vector[Directive] = Vector.empty, description: Option[StringValue] = None, comments: Vector[Comment] = Vector.empty, trailingComments: Vector[Comment] = Vector.empty, location: Option[AstLocation] = None) extends TypeDefinition with WithTrailingComments with WithDescription with Product with Serializable
- case class InputObjectTypeExtensionDefinition(name: String, fields: Vector[InputValueDefinition], directives: Vector[Directive] = Vector.empty, comments: Vector[Comment] = Vector.empty, trailingComments: Vector[Comment] = Vector.empty, location: Option[AstLocation] = None) extends TypeExtensionDefinition with WithTrailingComments with Product with Serializable
- case class InputValueDefinition(name: String, valueType: Type, defaultValue: Option[Value], directives: Vector[Directive] = Vector.empty, description: Option[StringValue] = None, comments: Vector[Comment] = Vector.empty, location: Option[AstLocation] = None) extends SchemaAstNode with WithDirectives with WithDescription with Product with Serializable
- case class IntValue(value: Int, comments: Vector[Comment] = Vector.empty, location: Option[AstLocation] = None) extends ScalarValue with Product with Serializable
- case class InterfaceTypeDefinition(name: String, fields: Vector[FieldDefinition], interfaces: Vector[NamedType], directives: Vector[Directive] = Vector.empty, description: Option[StringValue] = None, comments: Vector[Comment] = Vector.empty, trailingComments: Vector[Comment] = Vector.empty, location: Option[AstLocation] = None) extends TypeDefinition with WithTrailingComments with WithDescription with Product with Serializable
- case class InterfaceTypeExtensionDefinition(name: String, interfaces: Vector[NamedType], fields: Vector[FieldDefinition], directives: Vector[Directive] = Vector.empty, comments: Vector[Comment] = Vector.empty, trailingComments: Vector[Comment] = Vector.empty, location: Option[AstLocation] = None) extends ObjectLikeTypeExtensionDefinition with WithTrailingComments with Product with Serializable
- case class ListType(ofType: Type, location: Option[AstLocation] = None) extends Type with Product with Serializable
- case class ListValue(values: Vector[Value], comments: Vector[Comment] = Vector.empty, location: Option[AstLocation] = None) extends Value with Product with Serializable
- sealed trait NameValue extends AstNode with WithComments
- case class NamedType(name: String, location: Option[AstLocation] = None) extends Type with Product with Serializable
- case class NotNullType(ofType: Type, location: Option[AstLocation] = None) extends Type with Product with Serializable
- case class NullValue(comments: Vector[Comment] = Vector.empty, location: Option[AstLocation] = None) extends Value with Product with Serializable
- case class ObjectField(name: String, value: Value, comments: Vector[Comment] = Vector.empty, location: Option[AstLocation] = None) extends NameValue with Product with Serializable
- sealed trait ObjectLikeTypeExtensionDefinition extends TypeExtensionDefinition
- case class ObjectTypeDefinition(name: String, interfaces: Vector[NamedType], fields: Vector[FieldDefinition], directives: Vector[Directive] = Vector.empty, description: Option[StringValue] = None, comments: Vector[Comment] = Vector.empty, trailingComments: Vector[Comment] = Vector.empty, location: Option[AstLocation] = None) extends TypeDefinition with WithTrailingComments with WithDescription with Product with Serializable
- case class ObjectTypeExtensionDefinition(name: String, interfaces: Vector[NamedType], fields: Vector[FieldDefinition], directives: Vector[Directive] = Vector.empty, comments: Vector[Comment] = Vector.empty, trailingComments: Vector[Comment] = Vector.empty, location: Option[AstLocation] = None) extends ObjectLikeTypeExtensionDefinition with WithTrailingComments with Product with Serializable
- case class ObjectValue(fields: Vector[ObjectField], comments: Vector[Comment] = Vector.empty, location: Option[AstLocation] = None) extends Value with Product with Serializable
- case class OperationDefinition(operationType: OperationType = OperationType.Query, name: Option[String] = None, variables: Vector[VariableDefinition] = Vector.empty, directives: Vector[Directive] = Vector.empty, selections: Vector[Selection], comments: Vector[Comment] = Vector.empty, trailingComments: Vector[Comment] = Vector.empty, location: Option[AstLocation] = None) extends Definition with WithDirectives with SelectionContainer with Product with Serializable
A definition of a GraphQL operation.
A definition of a GraphQL operation.
Every GraphQL request invokes a specific operation, possibly with values to substitute into the operation's variables.
- name
The name of the operation. Optional only if there is only one operation in the document. Used for selecting the specific operation to invoke in a GraphQL request.
- variables
The variables that must be substituted into the operation. Values for these must be provided either by their defaults or with the GraphQL request.
- sealed trait OperationType extends AnyRef
A type of operation in a GraphQL model.
A type of operation in a GraphQL model.
Every GraphQL operation is either a query, mutation or subscription.
- case class OperationTypeDefinition(operation: OperationType, tpe: NamedType, comments: Vector[Comment] = Vector.empty, location: Option[AstLocation] = None) extends SchemaAstNode with Product with Serializable
- case class ScalarTypeDefinition(name: String, directives: Vector[Directive] = Vector.empty, description: Option[StringValue] = None, comments: Vector[Comment] = Vector.empty, location: Option[AstLocation] = None) extends TypeDefinition with WithDescription with Product with Serializable
- case class ScalarTypeExtensionDefinition(name: String, directives: Vector[Directive] = Vector.empty, comments: Vector[Comment] = Vector.empty, location: Option[AstLocation] = None) extends TypeExtensionDefinition with Product with Serializable
- sealed trait ScalarValue extends Value
- sealed trait SchemaAstNode extends AstNode with WithComments
- case class SchemaDefinition(operationTypes: Vector[OperationTypeDefinition], directives: Vector[Directive] = Vector.empty, description: Option[StringValue] = None, comments: Vector[Comment] = Vector.empty, trailingComments: Vector[Comment] = Vector.empty, location: Option[AstLocation] = None) extends TypeSystemDefinition with WithDescription with WithTrailingComments with WithDirectives with Product with Serializable
A definition of a GraphQL schema.
A definition of a GraphQL schema.
- operationTypes
The root operations available in this schema.
- case class SchemaExtensionDefinition(operationTypes: Vector[OperationTypeDefinition], directives: Vector[Directive] = Vector.empty, comments: Vector[Comment] = Vector.empty, trailingComments: Vector[Comment] = Vector.empty, location: Option[AstLocation] = None) extends TypeSystemExtensionDefinition with WithDirectives with WithTrailingComments with Product with Serializable
- sealed trait Selection extends AstNode with WithDirectives with WithComments
A component of information to be queried and returned.
A component of information to be queried and returned.
Most typically a selection is a field.
- sealed trait SelectionContainer extends AstNode with WithComments with WithTrailingComments
A GraphQL AST node that contains selections.
A GraphQL AST node that contains selections.
Most typically, this is a field that is of a composite type.
- trait SourceMapper extends AnyRef
Set of functions that convert a GraphQL source code location to human-readable strings.
Set of functions that convert a GraphQL source code location to human-readable strings.
When rendering the results of a GraphQL document parse, it's helpful to describe where parsing failed. This is the interface to that facility.
- trait SourceMapperInput extends AnyRef
- case class StringValue(value: String, block: Boolean = false, blockRawValue: Option[String] = None, comments: Vector[Comment] = Vector.empty, location: Option[AstLocation] = None) extends ScalarValue with Product with Serializable
- sealed trait Type extends AstNode
- sealed trait TypeDefinition extends TypeSystemDefinition with WithDirectives with WithDescription
- sealed trait TypeExtensionDefinition extends TypeSystemExtensionDefinition with WithDirectives
- sealed trait TypeSystemDefinition extends SchemaAstNode with Definition
- sealed trait TypeSystemExtensionDefinition extends SchemaAstNode with Definition
- case class UnionTypeDefinition(name: String, types: Vector[NamedType], directives: Vector[Directive] = Vector.empty, description: Option[StringValue] = None, comments: Vector[Comment] = Vector.empty, location: Option[AstLocation] = None) extends TypeDefinition with WithDescription with Product with Serializable
- case class UnionTypeExtensionDefinition(name: String, types: Vector[NamedType], directives: Vector[Directive] = Vector.empty, comments: Vector[Comment] = Vector.empty, location: Option[AstLocation] = None) extends TypeExtensionDefinition with Product with Serializable
- sealed trait Value extends AstNode with WithComments
A value that can be substituted into a GraphQL operation variable.
A value that can be substituted into a GraphQL operation variable.
Called "input values" in the GraphQL spec. Input values can be scalars, enumeration values, lists, objects, or null values.
- case class VariableDefinition(name: String, tpe: Type, defaultValue: Option[Value], directives: Vector[Directive] = Vector.empty, comments: Vector[Comment] = Vector.empty, location: Option[AstLocation] = None) extends AstNode with WithComments with WithDirectives with Product with Serializable
A definition of a variable to an operation.
A definition of a variable to an operation.
- name
Name of the variable being defined.
- defaultValue
Value that the variable should assume in an operation if none was provided with the GraphQL request.
- case class VariableValue(name: String, comments: Vector[Comment] = Vector.empty, location: Option[AstLocation] = None) extends Value with Product with Serializable
- sealed trait WithArguments extends AstNode
- sealed trait WithComments extends AstNode
- sealed trait WithDescription extends AstNode
- sealed trait WithDirectives extends AstNode
- sealed trait WithTrailingComments extends AnyRef
Value Members
- object AggregateSourceMapper
- object AstLocation extends Serializable
- object Document extends Serializable
- object InputDocument extends Serializable
- object InterfaceTypeDefinition extends Serializable
- object InterfaceTypeExtensionDefinition extends Serializable
- object ObjectValue extends Serializable
- object OperationType
Value nodes
Types that represent input value nodes in the GraphQL AST.
Scalar value nodes
Types that represent scalar input value nodes in the GraphQL AST.
Type system definition nodes
The GraphQL type system describes the capabilities of a GraphQL server and is used to determine if a query is valid. The type system also describes the input types of query variables to determine if values provided at runtime are valid. The GraphQL type system for a Sangria server is defined in terms of these classes, with the SchemaDefinition being the most important top-level class.