Package com.apollographql.apollo3.ast

Types

Link copied to clipboard
class ConversionException(val error: String, val sourceLocation: SourceLocation = SourceLocation.UNKNOWN) : SourceAwareException

An exception while converting to/from introspection

Link copied to clipboard
data class GQLArgument(    val sourceLocation: SourceLocation = SourceLocation.UNKNOWN,     val name: String,     val value: GQLValue) : GQLNode
Link copied to clipboard
data class GQLArguments(val arguments: List<GQLArgument>, val sourceLocation: SourceLocation = SourceLocation.UNKNOWN) : GQLNode
Link copied to clipboard
data class GQLBooleanValue(val sourceLocation: SourceLocation = SourceLocation.UNKNOWN, val value: Boolean) : GQLValue
Link copied to clipboard
interface GQLDefinition : GQLNode
Link copied to clipboard
interface GQLDescribed

A GQLNode that has a description

Link copied to clipboard
data class GQLDirective(    val sourceLocation: SourceLocation = SourceLocation.UNKNOWN,     val name: String,     val arguments: GQLArguments?) : GQLNode, GQLNamed
Link copied to clipboard
data class GQLDirectiveDefinition(    val sourceLocation: SourceLocation = SourceLocation.UNKNOWN,     val description: String?,     val name: String,     val arguments: List<GQLInputValueDefinition>,     val repeatable: Boolean,     val locations: List<GQLDirectiveLocation>) : GQLDefinition, GQLNamed
Link copied to clipboard
enum GQLDirectiveLocation : Enum<GQLDirectiveLocation>
Link copied to clipboard
data class GQLDocument(val definitions: List<GQLDefinition>, val filePath: String?) : GQLNode

The top level node in a GraphQL document. This can be a schema document or an executable document (or something else if need be)

Link copied to clipboard
data class GQLEnumTypeDefinition(    val sourceLocation: SourceLocation = SourceLocation.UNKNOWN,     val description: String?,     val name: String,     val directives: List<GQLDirective>,     val enumValues: List<GQLEnumValueDefinition>) : GQLTypeDefinition
Link copied to clipboard
data class GQLEnumTypeExtension(    val sourceLocation: SourceLocation = SourceLocation.UNKNOWN,     val name: String,     val directives: List<GQLDirective>,     val enumValues: List<GQLEnumValueDefinition>) : GQLDefinition, GQLTypeExtension
Link copied to clipboard
data class GQLEnumValue(val sourceLocation: SourceLocation = SourceLocation.UNKNOWN, val value: String) : GQLValue
Link copied to clipboard
data class GQLEnumValueDefinition(    val sourceLocation: SourceLocation = SourceLocation.UNKNOWN,     val description: String?,     val name: String,     val directives: List<GQLDirective>) : GQLNode, GQLNamed
Link copied to clipboard
data class GQLField(    val sourceLocation: SourceLocation = SourceLocation.UNKNOWN,     val alias: String?,     val name: String,     val arguments: GQLArguments?,     val directives: List<GQLDirective>,     val selectionSet: GQLSelectionSet?) : GQLSelection
Link copied to clipboard
data class GQLFieldDefinition(    val sourceLocation: SourceLocation = SourceLocation.UNKNOWN,     val description: String?,     val name: String,     val arguments: List<GQLInputValueDefinition>,     val type: GQLType,     val directives: List<GQLDirective>) : GQLNode, GQLNamed
Link copied to clipboard
data class GQLFloatValue(val sourceLocation: SourceLocation = SourceLocation.UNKNOWN, val value: Double) : GQLValue
Link copied to clipboard
data class GQLFragmentDefinition(    val sourceLocation: SourceLocation = SourceLocation.UNKNOWN,     val name: String,     val directives: List<GQLDirective>,     val typeCondition: GQLNamedType,     val selectionSet: GQLSelectionSet,     val description: String?) : GQLDefinition, GQLNamed, GQLDescribed
Link copied to clipboard
data class GQLFragmentSpread(    val sourceLocation: SourceLocation = SourceLocation.UNKNOWN,     val name: String,     val directives: List<GQLDirective>) : GQLSelection
Link copied to clipboard
data class GQLInlineFragment(    val sourceLocation: SourceLocation = SourceLocation.UNKNOWN,     val typeCondition: GQLNamedType,     val directives: List<GQLDirective>,     val selectionSet: GQLSelectionSet) : GQLSelection
Link copied to clipboard
data class GQLInputObjectTypeDefinition(    val sourceLocation: SourceLocation = SourceLocation.UNKNOWN,     val description: String?,     val name: String,     val directives: List<GQLDirective>,     val inputFields: List<GQLInputValueDefinition>) : GQLTypeDefinition
Link copied to clipboard
data class GQLInputObjectTypeExtension(    val sourceLocation: SourceLocation = SourceLocation.UNKNOWN,     val name: String,     val directives: List<GQLDirective>,     val inputFields: List<GQLInputValueDefinition>) : GQLDefinition, GQLTypeExtension
Link copied to clipboard
data class GQLInputValueDefinition(    val sourceLocation: SourceLocation = SourceLocation.UNKNOWN,     val description: String?,     val name: String,     val directives: List<GQLDirective>,     val type: GQLType,     val defaultValue: GQLValue?) : GQLNode, GQLNamed
Link copied to clipboard
data class GQLInterfaceTypeDefinition(    val sourceLocation: SourceLocation = SourceLocation.UNKNOWN,     val description: String?,     val name: String,     val implementsInterfaces: List<String>,     val directives: List<GQLDirective>,     val fields: List<GQLFieldDefinition>) : GQLTypeDefinition
Link copied to clipboard
data class GQLInterfaceTypeExtension(    val sourceLocation: SourceLocation = SourceLocation.UNKNOWN,     val name: String,     val implementsInterfaces: List<String>,     val directives: List<GQLDirective>,     val fields: List<GQLFieldDefinition>) : GQLDefinition, GQLTypeExtension, GQLNamed
Link copied to clipboard
data class GQLIntValue(val sourceLocation: SourceLocation = SourceLocation.UNKNOWN, val value: Int) : GQLValue
Link copied to clipboard
data class GQLListType(val sourceLocation: SourceLocation = SourceLocation.UNKNOWN, val type: GQLType) : GQLType
Link copied to clipboard
data class GQLListValue(val sourceLocation: SourceLocation = SourceLocation.UNKNOWN, val values: List<GQLValue>) : GQLValue
Link copied to clipboard
interface GQLNamed

A GQLNode that has a name

Link copied to clipboard
data class GQLNamedType(val sourceLocation: SourceLocation = SourceLocation.UNKNOWN, val name: String) : GQLType, GQLNamed
Link copied to clipboard
interface GQLNode

A node in the GraphQL AST.

Link copied to clipboard
data class GQLNonNullType(val sourceLocation: SourceLocation = SourceLocation.UNKNOWN, val type: GQLType) : GQLType
Link copied to clipboard
data class GQLNullValue(val sourceLocation: SourceLocation = SourceLocation.UNKNOWN) : GQLValue
Link copied to clipboard
data class GQLObjectField(    val sourceLocation: SourceLocation = SourceLocation.UNKNOWN,     val name: String,     val value: GQLValue) : GQLNode
Link copied to clipboard
data class GQLObjectTypeDefinition(    val sourceLocation: SourceLocation = SourceLocation.UNKNOWN,     val description: String?,     val name: String,     val implementsInterfaces: List<String>,     val directives: List<GQLDirective>,     val fields: List<GQLFieldDefinition>) : GQLTypeDefinition
Link copied to clipboard
data class GQLObjectTypeExtension(    val sourceLocation: SourceLocation = SourceLocation.UNKNOWN,     val name: String,     val implementsInterfaces: List<String>,     val directives: List<GQLDirective>,     val fields: List<GQLFieldDefinition>) : GQLDefinition, GQLTypeExtension
Link copied to clipboard
data class GQLObjectValue(val sourceLocation: SourceLocation = SourceLocation.UNKNOWN, val fields: List<GQLObjectField>) : GQLValue
Link copied to clipboard
data class GQLOperationDefinition(    val sourceLocation: SourceLocation = SourceLocation.UNKNOWN,     val operationType: String,     val name: String?,     val variableDefinitions: List<GQLVariableDefinition>,     val directives: List<GQLDirective>,     val selectionSet: GQLSelectionSet,     val description: String?) : GQLDefinition, GQLDescribed
Link copied to clipboard
data class GQLOperationTypeDefinition(    val sourceLocation: SourceLocation = SourceLocation.UNKNOWN,     val operationType: String,     val namedType: String) : GQLNode
Link copied to clipboard
class GQLResult<out V : Any>(val value: V?, val issues: List<Issue>)

The result of a parsing or validation operation. It's tri-state:

Link copied to clipboard
data class GQLScalarTypeDefinition(    val sourceLocation: SourceLocation = SourceLocation.UNKNOWN,     val description: String?,     val name: String,     val directives: List<GQLDirective>) : GQLTypeDefinition
Link copied to clipboard
data class GQLScalarTypeExtension(    val sourceLocation: SourceLocation = SourceLocation.UNKNOWN,     val name: String,     val directives: List<GQLDirective>) : GQLDefinition, GQLTypeExtension
Link copied to clipboard
data class GQLSchemaDefinition(    val sourceLocation: SourceLocation = SourceLocation.UNKNOWN,     val description: String?,     val directives: List<GQLDirective>,     val rootOperationTypeDefinitions: List<GQLOperationTypeDefinition>) : GQLDefinition
Link copied to clipboard
data class GQLSchemaExtension(    val sourceLocation: SourceLocation = SourceLocation.UNKNOWN,     val directives: List<GQLDirective>,     val operationTypesDefinition: List<GQLOperationTypeDefinition>) : GQLDefinition, GQLTypeSystemExtension
Link copied to clipboard
sealed class GQLSelection : GQLNode
Link copied to clipboard
data class GQLSelectionSet(val selections: List<GQLSelection>, val sourceLocation: SourceLocation = SourceLocation.UNKNOWN) : GQLNode
Link copied to clipboard
data class GQLStringValue(val sourceLocation: SourceLocation = SourceLocation.UNKNOWN, val value: String) : GQLValue
Link copied to clipboard
sealed class GQLType : GQLNode
Link copied to clipboard
sealed class GQLTypeDefinition : GQLDefinition, GQLNamed, GQLDescribed
Link copied to clipboard
interface GQLTypeExtension : GQLTypeSystemExtension, GQLNamed
Link copied to clipboard
interface GQLTypeSystemExtension : GQLNode
Link copied to clipboard
data class GQLUnionTypeDefinition(    val sourceLocation: SourceLocation = SourceLocation.UNKNOWN,     val description: String?,     val name: String,     val directives: List<GQLDirective>,     val memberTypes: List<GQLNamedType>) : GQLTypeDefinition
Link copied to clipboard
data class GQLUnionTypeExtension(    val sourceLocation: SourceLocation = SourceLocation.UNKNOWN,     val name: String,     val directives: List<GQLDirective>,     val memberTypes: List<GQLNamedType>) : GQLDefinition, GQLTypeExtension
Link copied to clipboard
sealed class GQLValue : GQLNode
Link copied to clipboard
data class GQLVariableDefinition(    val sourceLocation: SourceLocation = SourceLocation.UNKNOWN,     val name: String,     val type: GQLType,     val defaultValue: GQLValue?,     val directives: List<GQLDirective>) : GQLNode

A variable definition is very similar to an InputValue definition except it doesn't have a description

Link copied to clipboard
data class GQLVariableValue(val sourceLocation: SourceLocation = SourceLocation.UNKNOWN, val name: String) : GQLValue
Link copied to clipboard
class InferredVariable(val name: String, val type: GQLType)

A variable that is inferred from its usages in fragments This is used to create executable fragments

Link copied to clipboard
sealed class Issue

All the issues that can be collected while analyzing a graphql document

Link copied to clipboard
class NodeContainer(nodes: List<GQLNode>)
Link copied to clipboard
fun interface NodeTransformer
Link copied to clipboard
object QueryDocumentMinifier
Link copied to clipboard
class Schema

A wrapper around a schema GQLDocument that ensures the GQLDocument is valid and caches some extra information. In particular, Schema:

Link copied to clipboard
class SchemaValidationException(val error: String, val sourceLocation: SourceLocation = SourceLocation.UNKNOWN) : SourceAwareException

The schema is invalid

Link copied to clipboard
open class SDLWriter(sink: BufferedSink, indent: String) : Closeable

A SDLWriter writes utf8 text to the given sink and supports indent/unindent

Link copied to clipboard
open class SourceAwareException(val error: String, val sourceLocation: SourceLocation) : RuntimeException
Link copied to clipboard
class SourceLocation(    val line: Int,     val position: Int,     val filePath: String?)
Link copied to clipboard
interface TransformResult
Link copied to clipboard
class UnrecognizedAntlrRule(val error: String, val sourceLocation: SourceLocation) : SourceAwareException

Something went wrong while building the GraphQL AST, analyzing the schema, ...

Link copied to clipboard
enum ValidationDetails : Enum<ValidationDetails>
Link copied to clipboard
class VariableUsage(    val variable: GQLVariableValue,     val locationType: GQLType,     val hasLocationDefaultValue: Boolean)

A variable used in a GQLValue

Functions

Link copied to clipboard
fun apolloDefinitions(): List<GQLDefinition>

fun apolloDefinitions(version: String): List<GQLDefinition>

Extra apollo specific definitions from https://specs.apollo.dev/kotlin_labs/<[version]>

Link copied to clipboard
fun builtinDefinitions(): List<GQLDefinition>

Definitions from the spec

Link copied to clipboard
fun GQLTypeDefinition.canHaveKeyFields(): Boolean
Link copied to clipboard
fun checkKeyFields(    fragmentDefinition: GQLFragmentDefinition,     schema: Schema,     allFragmentDefinitions: Map<String, GQLFragmentDefinition>)
fun checkKeyFields(    operation: GQLOperationDefinition,     schema: Schema,     allFragmentDefinitions: Map<String, GQLFragmentDefinition>)
Link copied to clipboard
fun List<Issue>.checkNoErrors()
Link copied to clipboard
fun GQLValue.coerceInExecutableContextOrThrow(expectedType: GQLType, schema: Schema): GQLValue

For a GQLValue used in input position, validate that it can be coerced to expectedType and coerce it at the same time.

Link copied to clipboard
fun GQLValue.coerceInSchemaContextOrThrow(expectedType: GQLType, schema: Schema): GQLValue

For a GQLValue used in input position, validate that it can be coerced to expectedType and coerce it at the same time.

Link copied to clipboard
fun List<Issue>.containsError(): Boolean
Link copied to clipboard
fun String.decodeAsGraphQLSingleQuoted(): String
Link copied to clipboard
fun String.decodeAsGraphQLTripleQuoted(): String
Link copied to clipboard
fun GQLField.definitionFromScope(schema: Schema, parentTypeDefinition: GQLTypeDefinition): GQLFieldDefinition?
fun GQLField.definitionFromScope(schema: Schema, rawTypename: String): GQLFieldDefinition?
Link copied to clipboard
fun String.encodeToGraphQLSingleQuoted(): String

https://spec.graphql.org/draft/#EscapedCharacter

Link copied to clipboard
fun String.encodeToGraphQLTripleQuoted(): String
Link copied to clipboard
fun List<GQLDirective>.findDeprecationReason(): String?
Link copied to clipboard
fun List<GQLDirective>.findNonnull(schema: Schema): Boolean
Link copied to clipboard
fun List<GQLDirective>.findOptInFeature(schema: Schema): String?
Link copied to clipboard
fun List<GQLDirective>.findTargetName(schema: Schema): String?
Link copied to clipboard
fun GQLTypeDefinition.implementsAbstractType(schema: Schema): Boolean
Link copied to clipboard
fun GQLFragmentDefinition.inferVariables(    schema: Schema,     fragments: Map<String, GQLFragmentDefinition>,     fieldsOnDisjointTypesMustMerge: Boolean): List<InferredVariable>

Infers the variables from a given fragment

Link copied to clipboard
fun GQLTypeDefinition.isAbstract(): Boolean
Link copied to clipboard
Link copied to clipboard
fun GQLTypeDefinition.isFieldNonNull(fieldName: String, schema: Schema? = null): Boolean
Link copied to clipboard
fun GQLType.leafType(): GQLNamedType
Link copied to clipboard
fun linkDefinitions(): List<GQLDefinition>

The @link definition for bootstrapping

Link copied to clipboard
fun List<GQLDirective>.optionalValue(schema: Schema?): Boolean?
Link copied to clipboard
fun BufferedSource.parseAsGQLDocument(filePath: String? = null): GQLResult<GQLDocument>

Parses the source to a GQLDocument, validating the syntax but not the contents of the document.

Link copied to clipboard
fun BufferedSource.parseAsGQLSelections(filePath: String? = null): GQLResult<List<GQLSelection>>

Parses the source to a List<GQLSelection>, validating the syntax but not the contents of the selections.

Link copied to clipboard
fun BufferedSource.parseAsGQLValue(filePath: String? = null): GQLResult<GQLValue>

Parses the source to a GQLValue, validating the syntax but not the contents of the value.

Link copied to clipboard
fun GQLTypeDefinition.possibleTypes(schema: Schema): Set<String>
Link copied to clipboard
fun GQLType.pretty(): String
Link copied to clipboard
fun GQLType.rawType(): GQLNamedType

Returns the raw type. The raw type is the GQLNamedType without any list/nonnull wrapper types

Link copied to clipboard
fun GQLField.responseName(): String
Link copied to clipboard
fun GQLOperationDefinition.rootTypeDefinition(schema: Schema): GQLTypeDefinition?
Link copied to clipboard
fun BufferedSource.toExecutableDefinitions(    schema: Schema,     filePath: String? = null,     fieldsOnDisjointTypesMustMerge: Boolean = true): List<GQLDefinition>

Parses the source to a List<GQLDefinition>, throwing on parsing or validation errors.

Link copied to clipboard
fun BufferedSource.toSchema(filePath: String? = null): Schema

Parses the source to a Schema, throwing on parsing or validation errors.

Link copied to clipboard
fun GQLNode.toUtf8(indent: String = " "): String
fun GQLNode.toUtf8(file: File, indent: String = " ")
fun GQLNode.toUtf8(sink: BufferedSink, indent: String = " ")
Link copied to clipboard
fun GQLNode.transform(transformer: NodeTransformer): GQLNode?
Link copied to clipboard
fun GQLOperationDefinition.validate(    schema: Schema,     fragments: Map<String, GQLFragmentDefinition>,     fieldsOnDisjointTypesMustMerge: Boolean = true): List<Issue>
Link copied to clipboard
fun GQLDocument.validateAsExecutable(schema: Schema, fieldsOnDisjointTypesMustMerge: Boolean = true): GQLResult<List<GQLDefinition>>

Validates the given document as an executable document.

Link copied to clipboard

Validate the given document as a schema:

Link copied to clipboard
fun GQLDocument.withBuiltinDefinitions(): GQLDocument
Link copied to clipboard
fun GQLDocument.withoutBuiltinDefinitions(): GQLDocument