Package com.apollographql.apollo3.ast

Types

ConversionException
Link copied to clipboard
class ConversionException(error: String, sourceLocation: SourceLocation) : SourceAwareException
An exception while converting to/from introspectionThis most likely means the json/sdl was inconsistent or corrupted
GQLArgument
Link copied to clipboard
data class GQLArgument(sourceLocation: SourceLocation, name: String, value: GQLValue) : GQLNode
GQLArguments
Link copied to clipboard
data class GQLArguments(arguments: List<GQLArgument>, sourceLocation: SourceLocation) : GQLNode
GQLBooleanValue
Link copied to clipboard
data class GQLBooleanValue(sourceLocation: SourceLocation, value: Boolean) : GQLValue
GQLDefinition
Link copied to clipboard
interface GQLDefinition : GQLNode
GQLDescribed
Link copied to clipboard
interface GQLDescribed
A GQLNode that has a description
GQLDirective
Link copied to clipboard
data class GQLDirective(sourceLocation: SourceLocation, name: String, arguments: GQLArguments?) : GQLNode, GQLNamed
GQLDirectiveDefinition
Link copied to clipboard
data class GQLDirectiveDefinition(sourceLocation: SourceLocation, description: String?, name: String, arguments: List<GQLInputValueDefinition>, repeatable: Boolean, locations: List<GQLDirectiveLocation>) : GQLDefinition, GQLNamed
GQLDirectiveLocation
Link copied to clipboard
enum GQLDirectiveLocation : Enum<GQLDirectiveLocation>
GQLDocument
Link copied to clipboard
data class GQLDocument(definitions: List<GQLDefinition>, filePath: String?) : GQLNode
The top level node in a GraphQL document.
GQLEnumTypeDefinition
Link copied to clipboard
data class GQLEnumTypeDefinition(sourceLocation: SourceLocation, description: String?, name: String, directives: List<GQLDirective>, enumValues: List<GQLEnumValueDefinition>) : GQLTypeDefinition
GQLEnumTypeExtension
Link copied to clipboard
data class GQLEnumTypeExtension(sourceLocation: SourceLocation, name: String, directives: List<GQLDirective>, enumValues: List<GQLEnumValueDefinition>) : GQLDefinition, GQLTypeExtension
GQLEnumValue
Link copied to clipboard
data class GQLEnumValue(sourceLocation: SourceLocation, value: String) : GQLValue
GQLEnumValueDefinition
Link copied to clipboard
data class GQLEnumValueDefinition(sourceLocation: SourceLocation, description: String?, name: String, directives: List<GQLDirective>) : GQLNode, GQLNamed
GQLField
Link copied to clipboard
data class GQLField(sourceLocation: SourceLocation, alias: String?, name: String, arguments: GQLArguments?, directives: List<GQLDirective>, selectionSet: GQLSelectionSet?) : GQLSelection
GQLFieldDefinition
Link copied to clipboard
data class GQLFieldDefinition(sourceLocation: SourceLocation, description: String?, name: String, arguments: List<GQLInputValueDefinition>, type: GQLType, directives: List<GQLDirective>) : GQLNode, GQLNamed
GQLFloatValue
Link copied to clipboard
data class GQLFloatValue(sourceLocation: SourceLocation, value: Double) : GQLValue
GQLFragmentDefinition
Link copied to clipboard
data class GQLFragmentDefinition(sourceLocation: SourceLocation, name: String, directives: List<GQLDirective>, typeCondition: GQLNamedType, selectionSet: GQLSelectionSet, description: String?) : GQLDefinition, GQLNamed, GQLDescribed
GQLFragmentSpread
Link copied to clipboard
data class GQLFragmentSpread(sourceLocation: SourceLocation, name: String, directives: List<GQLDirective>) : GQLSelection
GQLInlineFragment
Link copied to clipboard
data class GQLInlineFragment(sourceLocation: SourceLocation, typeCondition: GQLNamedType, directives: List<GQLDirective>, selectionSet: GQLSelectionSet) : GQLSelection
GQLInputObjectTypeDefinition
Link copied to clipboard
data class GQLInputObjectTypeDefinition(sourceLocation: SourceLocation, description: String?, name: String, directives: List<GQLDirective>, inputFields: List<GQLInputValueDefinition>) : GQLTypeDefinition
GQLInputObjectTypeExtension
Link copied to clipboard
data class GQLInputObjectTypeExtension(sourceLocation: SourceLocation, name: String, directives: List<GQLDirective>, inputFields: List<GQLInputValueDefinition>) : GQLDefinition, GQLTypeExtension
GQLInputValueDefinition
Link copied to clipboard
data class GQLInputValueDefinition(sourceLocation: SourceLocation, description: String?, name: String, directives: List<GQLDirective>, type: GQLType, defaultValue: GQLValue?) : GQLNode, GQLNamed
GQLInterfaceTypeDefinition
Link copied to clipboard
data class GQLInterfaceTypeDefinition(sourceLocation: SourceLocation, description: String?, name: String, implementsInterfaces: List<String>, directives: List<GQLDirective>, fields: List<GQLFieldDefinition>) : GQLTypeDefinition
GQLInterfaceTypeExtension
Link copied to clipboard
data class GQLInterfaceTypeExtension(sourceLocation: SourceLocation, name: String, implementsInterfaces: List<String>, fields: List<GQLFieldDefinition>) : GQLDefinition, GQLTypeExtension, GQLNamed
GQLIntValue
Link copied to clipboard
data class GQLIntValue(sourceLocation: SourceLocation, value: Int) : GQLValue
GQLListType
Link copied to clipboard
data class GQLListType(sourceLocation: SourceLocation, type: GQLType) : GQLType
GQLListValue
Link copied to clipboard
data class GQLListValue(sourceLocation: SourceLocation, values: List<GQLValue>) : GQLValue
GQLNamed
Link copied to clipboard
interface GQLNamed
A GQLNode that has a name
GQLNamedType
Link copied to clipboard
data class GQLNamedType(sourceLocation: SourceLocation, name: String) : GQLType, GQLNamed
GQLNode
Link copied to clipboard
interface GQLNode
A node in the GraphQL AST.
GQLNonNullType
Link copied to clipboard
data class GQLNonNullType(sourceLocation: SourceLocation, type: GQLType) : GQLType
GQLNullValue
Link copied to clipboard
data class GQLNullValue(sourceLocation: SourceLocation) : GQLValue
GQLObjectField
Link copied to clipboard
data class GQLObjectField(sourceLocation: SourceLocation, name: String, value: GQLValue) : GQLNode
GQLObjectTypeDefinition
Link copied to clipboard
data class GQLObjectTypeDefinition(sourceLocation: SourceLocation, description: String?, name: String, implementsInterfaces: List<String>, directives: List<GQLDirective>, fields: List<GQLFieldDefinition>) : GQLTypeDefinition
GQLObjectTypeExtension
Link copied to clipboard
data class GQLObjectTypeExtension(sourceLocation: SourceLocation, name: String, implementsInterfaces: List<String>, directives: List<GQLDirective>, fields: List<GQLFieldDefinition>) : GQLDefinition, GQLTypeExtension
GQLObjectValue
Link copied to clipboard
data class GQLObjectValue(sourceLocation: SourceLocation, fields: List<GQLObjectField>) : GQLValue
GQLOperationDefinition
Link copied to clipboard
data class GQLOperationDefinition(sourceLocation: SourceLocation, operationType: String, name: String?, variableDefinitions: List<GQLVariableDefinition>, directives: List<GQLDirective>, selectionSet: GQLSelectionSet, description: String?) : GQLDefinition, GQLDescribed
GQLOperationTypeDefinition
Link copied to clipboard
data class GQLOperationTypeDefinition(sourceLocation: SourceLocation, operationType: String, namedType: String) : GQLNode
GQLResult
Link copied to clipboard
class GQLResult<out V : Any>(value: V?, issues: List<Issue>)
The result of a parsing or validation operation.
GQLScalarTypeDefinition
Link copied to clipboard
data class GQLScalarTypeDefinition(sourceLocation: SourceLocation, description: String?, name: String, directives: List<GQLDirective>) : GQLTypeDefinition
GQLScalarTypeExtension
Link copied to clipboard
data class GQLScalarTypeExtension(sourceLocation: SourceLocation, name: String, directives: List<GQLDirective>) : GQLDefinition, GQLTypeExtension
GQLSchemaDefinition
Link copied to clipboard
data class GQLSchemaDefinition(sourceLocation: SourceLocation, description: String?, directives: List<GQLDirective>, rootOperationTypeDefinitions: List<GQLOperationTypeDefinition>) : GQLDefinition
GQLSchemaExtension
Link copied to clipboard
data class GQLSchemaExtension(sourceLocation: SourceLocation, directives: List<GQLDirective>, operationTypesDefinition: List<GQLOperationTypeDefinition>) : GQLDefinition, GQLTypeSystemExtension
GQLSelection
Link copied to clipboard
sealed class GQLSelection : GQLNode
GQLSelectionSet
Link copied to clipboard
data class GQLSelectionSet(selections: List<GQLSelection>, sourceLocation: SourceLocation) : GQLNode
GQLStringValue
Link copied to clipboard
data class GQLStringValue(sourceLocation: SourceLocation, value: String) : GQLValue
GQLType
Link copied to clipboard
sealed class GQLType : GQLNode
GQLTypeDefinition
Link copied to clipboard
sealed class GQLTypeDefinition : GQLDefinition, GQLNamed, GQLDescribed
GQLTypeExtension
Link copied to clipboard
interface GQLTypeExtension : GQLTypeSystemExtension, GQLNamed
GQLTypeSystemExtension
Link copied to clipboard
interface GQLTypeSystemExtension : GQLNode
GQLUnionTypeDefinition
Link copied to clipboard
data class GQLUnionTypeDefinition(sourceLocation: SourceLocation, description: String?, name: String, directives: List<GQLDirective>, memberTypes: List<GQLNamedType>) : GQLTypeDefinition
GQLUnionTypeExtension
Link copied to clipboard
data class GQLUnionTypeExtension(sourceLocation: SourceLocation, name: String, directives: List<GQLDirective>, memberTypes: List<GQLNamedType>) : GQLDefinition, GQLTypeExtension
GQLValue
Link copied to clipboard
sealed class GQLValue : GQLNode
GQLVariableDefinition
Link copied to clipboard
data class GQLVariableDefinition(sourceLocation: SourceLocation, name: String, type: GQLType, defaultValue: GQLValue?, directives: List<GQLDirective>) : GQLNode
A variable definition is very similar to an InputValue definition except it doesn't have a description
GQLVariableValue
Link copied to clipboard
data class GQLVariableValue(sourceLocation: SourceLocation, name: String) : GQLValue
Issue
Link copied to clipboard
sealed class Issue
All the issues that can be collected while analyzing a graphql document
NodeContainer
Link copied to clipboard
class NodeContainer(nodes: List<GQLNode>)
NodeTransformer
Link copied to clipboard
fun fun interface NodeTransformer
Schema
Link copied to clipboard
class Schema(definitions: List<GQLDefinition>)
A wrapper around a schema GQLDocument that:
  • always contain builtin types contrary to introspection that will not contain directives and SDL that will not contain any builtin definitions

  • always has a schema definition

  • has type extensions merged

  • has some helper functions to retrieve a type by name and/or possible types

SchemaValidationException
Link copied to clipboard
class SchemaValidationException(error: String, sourceLocation: SourceLocation) : SourceAwareException
The schema is invalidTODO: transform this into issues
SDLWriter
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
SourceAwareException
Link copied to clipboard
open class SourceAwareException(error: String, sourceLocation: SourceLocation) : RuntimeException
SourceLocation
Link copied to clipboard
class SourceLocation(line: Int, position: Int, filePath: String?)
TransformResult
Link copied to clipboard
interface TransformResult
UnrecognizedAntlrRule
Link copied to clipboard
class UnrecognizedAntlrRule(error: String, sourceLocation: SourceLocation) : SourceAwareException
Something went wrong while building the GraphQL AST, analyzing the schema, ...
ValidationDetails
Link copied to clipboard
enum ValidationDetails : Enum<ValidationDetails>
VariableReference
Link copied to clipboard
class VariableReference(variable: GQLVariableValue, expectedType: GQLType)
A variable used in a GQLValue

Functions

apolloDefinitions
Link copied to clipboard
fun apolloDefinitions(): List<GQLDefinition>
Extra apollo specific definitions
builtinDefinitions
Link copied to clipboard
fun builtinDefinitions(): List<GQLDefinition>
Definitions from the spec
checkKeyFields
Link copied to clipboard
fun checkKeyFields(fragmentDefinition: GQLFragmentDefinition, schema: Schema, allFragmentDefinitions: Map<String, GQLFragmentDefinition>)
fun checkKeyFields(operation: GQLOperationDefinition, schema: Schema, allFragmentDefinitions: Map<String, GQLFragmentDefinition>)
checkNoErrors
Link copied to clipboard
fun List<Issue>.checkNoErrors()
coerceInExecutableContextOrThrow
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.
coerceInSchemaContextOrThrow
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.
containsError
Link copied to clipboard
fun List<Issue>.containsError(): Boolean
decodeAsGraphQLSingleQuoted
Link copied to clipboard
fun String.decodeAsGraphQLSingleQuoted(): String
decodeAsGraphQLTripleQuoted
Link copied to clipboard
fun String.decodeAsGraphQLTripleQuoted(): String
definitionFromScope
Link copied to clipboard
fun GQLField.definitionFromScope(schema: Schema, typeDefinitionInScope: GQLTypeDefinition): GQLFieldDefinition?
fun GQLField.definitionFromScope(schema: Schema, rawTypename: String): GQLFieldDefinition?
encodeToGraphQLSingleQuoted
Link copied to clipboard
fun String.encodeToGraphQLSingleQuoted(): String
https://spec.graphql.
encodeToGraphQLTripleQuoted
Link copied to clipboard
fun String.encodeToGraphQLTripleQuoted(): String
findDeprecationReason
Link copied to clipboard
fun List<GQLDirective>.findDeprecationReason(): String?
findNonnull
Link copied to clipboard
fun List<GQLDirective>.findNonnull(): Boolean
inferVariables
Link copied to clipboard
@ApolloExperimental()
fun GQLFragmentDefinition.inferVariables(schema: Schema, fragments: Map<String, GQLFragmentDefinition>): List<VariableReference>
Infers the variables from a given fragment
isApollo
Link copied to clipboard
fun GQLDirective.isApollo(): Boolean
isFieldNonNull
Link copied to clipboard
fun GQLTypeDefinition.isFieldNonNull(fieldName: String): Boolean
leafType
Link copied to clipboard
fun GQLType.leafType(): GQLNamedType
optionalValue
Link copied to clipboard
fun List<GQLDirective>.optionalValue(): Boolean?
parseAsGQLDocument
Link copied to clipboard
@ApolloExperimental()
fun BufferedSource.parseAsGQLDocument(filePath: String? = null): GQLResult<GQLDocument>
Parses the source to a GQLDocument, validating the syntax but not the contents of the document.
parseAsGQLSelections
Link copied to clipboard
@ApolloExperimental()
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.
parseAsGQLValue
Link copied to clipboard
@ApolloExperimental()
fun BufferedSource.parseAsGQLValue(filePath: String? = null): GQLResult<GQLValue>
Parses the source to a GQLValue, validating the syntax but not the contents of the value.
possibleTypes
Link copied to clipboard
fun GQLTypeDefinition.possibleTypes(schema: Schema): Set<String>
pretty
Link copied to clipboard
fun GQLType.pretty(): String
responseName
Link copied to clipboard
fun GQLField.responseName(): String
rootTypeDefinition
Link copied to clipboard
fun GQLOperationDefinition.rootTypeDefinition(schema: Schema): GQLTypeDefinition?
toExecutableDefinitions
Link copied to clipboard
@ApolloExperimental()
fun BufferedSource.toExecutableDefinitions(schema: Schema, filePath: String? = null): List<GQLDefinition>
Parses the source to a List<GQLDefinition>, throwing on parsing or validation errors.
toSchema
Link copied to clipboard
@ApolloExperimental()
fun BufferedSource.toSchema(filePath: String? = null): Schema
Parses the source to a Schema, throwing on parsing or validation errors.
toUtf8
Link copied to clipboard
fun GQLNode.toUtf8(indent: String = " "): String
fun GQLNode.toUtf8(file: File, indent: String = " ")
fun GQLNode.toUtf8(sink: BufferedSink, indent: String = " ")
transform
Link copied to clipboard
fun GQLNode.transform(transformer: NodeTransformer): GQLNode?
validate
Link copied to clipboard
fun GQLOperationDefinition.validate(schema: Schema, fragments: Map<String, GQLFragmentDefinition>): List<Issue>
validateAsExecutable
Link copied to clipboard
@ApolloExperimental()
fun GQLDocument.validateAsExecutable(schema: Schema): GQLResult<List<GQLDefinition>>
Validates the given document as an executable document.
validateAsSchema
Link copied to clipboard
@ApolloExperimental()
fun GQLDocument.validateAsSchema(): GQLResult<Schema>
  • Validate the given document as a schema.

  • Add a schema definition if there is none

  • Merge type extensions

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