Packages

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.

Linear Supertypes
Content Hierarchy
Ordering
  1. Grouped
  2. Alphabetic
  3. By Inheritance
Inherited
  1. ast
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Type Members

  1. 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.

  2. case class Argument(name: String, value: Value, comments: Vector[Comment] = Vector.empty, location: Option[AstLocation] = None) extends NameValue with Product with Serializable
  3. 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.

  4. sealed trait AstNode extends AnyRef

    A node in the AST of a parsed GraphQL request document.

  5. case class BigDecimalValue(value: BigDecimal, comments: Vector[Comment] = Vector.empty, location: Option[AstLocation] = None) extends ScalarValue with Product with Serializable

  6. case class BigIntValue(value: BigInt, comments: Vector[Comment] = Vector.empty, location: Option[AstLocation] = None) extends ScalarValue with Product with Serializable

  7. case class BooleanValue(value: Boolean, comments: Vector[Comment] = Vector.empty, location: Option[AstLocation] = None) extends ScalarValue with Product with Serializable

  8. case class Comment(text: String, location: Option[AstLocation] = None) extends AstNode with Product with Serializable
  9. sealed trait ConditionalFragment extends AstNode
  10. class DefaultSourceMapper extends SourceMapper

    sangria.ast.SourceMapper for a single GraphQL document.

  11. 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.

    See also

    https://spec.graphql.org/June2018/#Definition

  12. 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
  13. 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

  14. case class DirectiveLocation(name: String, comments: Vector[Comment] = Vector.empty, location: Option[AstLocation] = None) extends SchemaAstNode with Product with Serializable

  15. 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.

    See also

    https://spec.graphql.org/June2018/#Document

  16. 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

  17. 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

  18. case class EnumValue(value: String, comments: Vector[Comment] = Vector.empty, location: Option[AstLocation] = None) extends Value with Product with Serializable

  19. 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

  20. 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

  21. 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

  22. case class FloatValue(value: Double, comments: Vector[Comment] = Vector.empty, location: Option[AstLocation] = None) extends ScalarValue with Product with Serializable

  23. 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
  24. case class FragmentSpread(name: String, directives: Vector[Directive], comments: Vector[Comment] = Vector.empty, location: Option[AstLocation] = None) extends Selection with Product with Serializable
  25. 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
  26. 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
  27. 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

  28. 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

  29. 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

  30. case class IntValue(value: Int, comments: Vector[Comment] = Vector.empty, location: Option[AstLocation] = None) extends ScalarValue with Product with Serializable

  31. 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

  32. 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

  33. case class ListType(ofType: Type, location: Option[AstLocation] = None) extends Type with Product with Serializable
  34. case class ListValue(values: Vector[Value], comments: Vector[Comment] = Vector.empty, location: Option[AstLocation] = None) extends Value with Product with Serializable

  35. sealed trait NameValue extends AstNode with WithComments
  36. case class NamedType(name: String, location: Option[AstLocation] = None) extends Type with Product with Serializable
  37. case class NotNullType(ofType: Type, location: Option[AstLocation] = None) extends Type with Product with Serializable
  38. case class NullValue(comments: Vector[Comment] = Vector.empty, location: Option[AstLocation] = None) extends Value with Product with Serializable

  39. case class ObjectField(name: String, value: Value, comments: Vector[Comment] = Vector.empty, location: Option[AstLocation] = None) extends NameValue with Product with Serializable
  40. sealed trait ObjectLikeTypeExtensionDefinition extends TypeExtensionDefinition

  41. 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

  42. 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

  43. case class ObjectValue(fields: Vector[ObjectField], comments: Vector[Comment] = Vector.empty, location: Option[AstLocation] = None) extends Value with Product with Serializable

  44. 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.

    See also

    https://spec.graphql.org/June2018/#OperationDefinition

  45. 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.

    See also

    https://spec.graphql.org/June2018/#OperationType

  46. case class OperationTypeDefinition(operation: OperationType, tpe: NamedType, comments: Vector[Comment] = Vector.empty, location: Option[AstLocation] = None) extends SchemaAstNode with Product with Serializable

  47. 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

  48. 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

  49. sealed trait ScalarValue extends Value

  50. sealed trait SchemaAstNode extends AstNode with WithComments

  51. 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.

    See also

    https://spec.graphql.org/June2018/#sec-Schema

  52. 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

  53. 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.

    See also

    https://spec.graphql.org/June2018/#Selection

  54. 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.

  55. 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.

  56. trait SourceMapperInput extends AnyRef
  57. 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

  58. sealed trait Type extends AstNode
  59. sealed trait TypeDefinition extends TypeSystemDefinition with WithDirectives with WithDescription

  60. sealed trait TypeExtensionDefinition extends TypeSystemExtensionDefinition with WithDirectives

  61. sealed trait TypeSystemDefinition extends SchemaAstNode with Definition

  62. sealed trait TypeSystemExtensionDefinition extends SchemaAstNode with Definition

  63. 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

  64. 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

  65. 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.

    See also

    https://spec.graphql.org/June2018/#Value

  66. 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.

    See also

    https://spec.graphql.org/June2018/#VariableDefinition

  67. case class VariableValue(name: String, comments: Vector[Comment] = Vector.empty, location: Option[AstLocation] = None) extends Value with Product with Serializable

  68. sealed trait WithArguments extends AstNode
  69. sealed trait WithComments extends AstNode
  70. sealed trait WithDescription extends AstNode
  71. sealed trait WithDirectives extends AstNode
  72. sealed trait WithTrailingComments extends AnyRef

Inherited from AnyRef

Inherited from Any

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.

Ungrouped