Package com.apollographql.apollo3.api

Types

Adapter
Link copied to clipboard
common
interface Adapter<T>
An Adapter is responsible for adapting Kotlin-generated GraphQL types to/from their Json representation.
AnyAdapter
Link copied to clipboard
common
object AnyAdapter : Adapter<Any>
ApolloRequest
Link copied to clipboard
common
class ApolloRequest<D : Operation.Data> constructor(operation: Operation<D>, requestUuid: Uuid, executionContext: ExecutionContext) : HasExecutionContext
A GraphQL request to execute.
ApolloResponse
Link copied to clipboard
common
class ApolloResponse<out D : Operation.Data>(requestUuid: Uuid, operation: Operation<*>, data: D?, errors: List<Error>?, extensions: Map<String, Any?>, executionContext: ExecutionContext)
Represents a GraphQL response.
BooleanAdapter
Link copied to clipboard
common
object BooleanAdapter : Adapter<Boolean>
BooleanExpression
Link copied to clipboard
common
sealed class BooleanExpression<out T : Any>
A boolean expression
BPossibleTypes
Link copied to clipboard
common
data class BPossibleTypes(possibleTypes: Set<String>) : BTerm
A term that comes from a fragment type condition and that needs to be matched against __typename
BTerm
Link copied to clipboard
common
sealed class BTerm
A generic term in a BooleanExpression
BVariable
Link copied to clipboard
common
data class BVariable(name: String) : BTerm
A term that comes from @include/@skip directives and that needs to be matched against operation variables
CompiledArgument
Link copied to clipboard
common
class CompiledArgument(name: String, value: Any?, isKey: Boolean)
The Kotlin representation of a GraphQL argumentvalue can beNote: for now, enums are mapped to Strings
CompiledCondition
Link copied to clipboard
common
data class CompiledCondition(name: String, inverted: Boolean)
CompiledField
Link copied to clipboard
common
class CompiledField : CompiledSelection
A compiled field from a GraphQL operation
CompiledFragment
Link copied to clipboard
common
class CompiledFragment : CompiledSelection
A compiled inline fragment or fragment spread
CompiledListType
Link copied to clipboard
common
class CompiledListType(ofType: CompiledType) : CompiledType
CompiledNamedType
Link copied to clipboard
common
sealed class CompiledNamedType : CompiledType
CompiledNotNullType
Link copied to clipboard
common
class CompiledNotNullType(ofType: CompiledType) : CompiledType
CompiledSelection
Link copied to clipboard
common
sealed class CompiledSelection
CompiledType
Link copied to clipboard
common
sealed class CompiledType
CompiledVariable
Link copied to clipboard
common
class CompiledVariable(name: String)
The Kotlin representation of a GraphQL variable value
CustomScalarAdapters
Link copied to clipboard
common
class CustomScalarAdapters constructor(customScalarAdapters: Map<String, Adapter<*>>) : ExecutionContext.Element
A wrapper around a Map<String, Adapter> used to retrieve custom scalar adapters at runtime
CustomScalarType
Link copied to clipboard
common
class CustomScalarType(name: String, className: String) : CompiledNamedType
CustomTypeAdapter
Link copied to clipboard
common
interface CustomTypeAdapter<T>
A replica of Apollo Android v2's CustomTypeAdapter, to ease migration from v2 to v3.
CustomTypeValue
Link copied to clipboard
common
open class CustomTypeValue<T>(value: T)
A replica of Apollo Android v2's CustomTypeValue, to ease migration from v2 to v3.
DoubleAdapter
Link copied to clipboard
common
object DoubleAdapter : Adapter<Double>
EnumType
Link copied to clipboard
common
class EnumType(name: String) : CompiledNamedType
Error
Link copied to clipboard
common
class Error(message: String, locations: List<Error.Location>?, path: List<Any>?, extensions: Map<String, Any?>?, nonStandardFields: Map<String, Any?>?)
Represents an error response returned from the GraphQL server See https://spec.graphql.org/draft/#sec-Errors.
Executable
Link copied to clipboard
common
interface Executable<D : Executable.Data>
Base interface for Operation and Fragment that have an Adapter and Variables.
ExecutionContext
Link copied to clipboard
common
interface ExecutionContext
A context of GraphQL operation execution, represented as a set of Key keys and corresponding Element values.
FloatAdapter
Link copied to clipboard
common
object FloatAdapter : Adapter<Float>
An Adapter that converts to/from a Float Floats are not part of the GraphQL spec but this can be used in custom scalars
Fragment
Link copied to clipboard
common
interface Fragment<D : Fragment.Data> : Executable<D>
Base interface for a fragment implementation.
HasExecutionContext
Link copied to clipboard
common
interface HasExecutionContext
Implemented by classes that have an ExecutionContext: ApolloClient and ApolloRequest.
HasMutableExecutionContext
Link copied to clipboard
common
Implemented by classes whose ExecutionContext can be mutated: ApolloClient.
ImmutableMapBuilder
Link copied to clipboard
common
class ImmutableMapBuilder<K, V>
A helper class to make it easier to build Maps from the java codegen
Input
Link copied to clipboard
common
class Input
InputObjectType
Link copied to clipboard
common
class InputObjectType(name: String) : CompiledNamedType
IntAdapter
Link copied to clipboard
common
object IntAdapter : Adapter<Int>
InterfaceType
Link copied to clipboard
common
class InterfaceType(name: String, keyFields: List<String>, implements: List<InterfaceType>) : CompiledNamedType
ListAdapter
Link copied to clipboard
common
class ListAdapter<T>(wrappedAdapter: Adapter<T>) : Adapter<List<@JvmSuppressWildcards() T>>
This file contains a list of Adapter for standard typesThey are mostly used from the generated code but could be useful in any other situations that requires adapting from GraphQL to Kotlin.
LongAdapter
Link copied to clipboard
common
object LongAdapter : Adapter<Long>
An Adapter that converts to/from a Long Longs are not part of the GraphQL spec but this can be used in custom scalarsIf the Json number does not fit in a Long, an exception will be thrown
Mutation
Link copied to clipboard
common
interface Mutation<D : Mutation.Data> : Operation<D>
Represents a GraphQL mutation operation that will be sent to the server.
NullableAdapter
Link copied to clipboard
common
class NullableAdapter<T : Any>(wrappedAdapter: Adapter<T>) : Adapter<@JvmSuppressWildcards() T?>
ObjectAdapter
Link copied to clipboard
common
class ObjectAdapter<T>(wrappedAdapter: Adapter<T>, buffered: Boolean) : Adapter<@JvmSuppressWildcards() T>
ObjectType
Link copied to clipboard
common
class ObjectType(name: String, keyFields: List<String>, implements: List<InterfaceType>) : CompiledNamedType
Operation
Link copied to clipboard
common
interface Operation<D : Operation.Data> : Executable<D>
Represents a GraphQL operation (mutation, query or subscription).
Optional
Link copied to clipboard
common
sealed class Optional<out V>
A sealed class that can either be Present or AbsentIt provides a convenient way to distinguish the case when a value is provided explicitly and should be serialized (even if it's null) and the case where it's absent and shouldn't be serialized.
OptionalAdapter
Link copied to clipboard
common
class OptionalAdapter<T>(wrappedAdapter: Adapter<T>) : Adapter<Optional.Present<@JvmSuppressWildcards() T>>
ResponseAdapters can only express something that's present.
Query
Link copied to clipboard
common
interface Query<D : Query.Data> : Operation<D>
Represents a GraphQL query that will be sent to the server.
QueryDocumentMinifier
Link copied to clipboard
common
object QueryDocumentMinifier
ScalarType
Link copied to clipboard
common
class ScalarType(name: String) : CompiledNamedType
StringAdapter
Link copied to clipboard
common
object StringAdapter : Adapter<String>
Subscription
Link copied to clipboard
common
interface Subscription<D : Subscription.Data> : Operation<D>
Represents a GraphQL subscription.
Throws
Link copied to clipboard
annotation class Throws(exceptionClasses: KClass<out Throwable>)
typealias Throws = Throws
UnionType
Link copied to clipboard
common
class UnionType(name: String, members: ObjectType) : CompiledNamedType
Upload
Link copied to clipboard
common
interface Upload
A class that represents a file upload in a multipart upload See https://github.
UploadAdapter
Link copied to clipboard
common
object UploadAdapter : Adapter<Upload>

Functions

and
Link copied to clipboard
common
fun <T : Any> and(vararg other: BooleanExpression<T>): BooleanExpression<T>
fun <T : Any> BooleanExpression<T>.and(vararg other: BooleanExpression<T>): BooleanExpression<T>
checkFieldNotMissing
Link copied to clipboard
common
fun checkFieldNotMissing(value: Any?, name: String)
Helper function for the JavaCodegen
composeJsonData
Link copied to clipboard
common
fun <D : Operation.Data> Operation<D>.composeJsonData(data: D): String
fun <D : Operation.Data> Operation<D>.composeJsonData(sink: BufferedSink, data: D)
fun <D : Operation.Data> Operation<D>.composeJsonData(data: D, customScalarAdapters: CustomScalarAdapters, indent: String): String
fun <D : Operation.Data> Operation<D>.composeJsonData(sink: BufferedSink, data: D, customScalarAdapters: CustomScalarAdapters, indent: String)
writes operation data to the given sinkUse this for testing/mocking a valid GraphQL response
composeJsonRequest
Link copied to clipboard
common
fun <D : Operation.Data> Operation<D>.composeJsonRequest(): String
fun <D : Operation.Data> Operation<D>.composeJsonRequest(customScalarAdapters: CustomScalarAdapters): String
fun <D : Operation.Data> Operation<D>.composeJsonRequest(sink: BufferedSink)
fun <D : Operation.Data> Operation<D>.composeJsonRequest(sink: BufferedSink, customScalarAdapters: CustomScalarAdapters)
writes the body of a GraphQL json request like below: { "query": ...
composeJsonResponse
Link copied to clipboard
common
fun <D : Operation.Data> Operation<D>.composeJsonResponse(data: D): String
fun <D : Operation.Data> Operation<D>.composeJsonResponse(sink: BufferedSink, data: D)
fun <D : Operation.Data> Operation<D>.composeJsonResponse(data: D, customScalarAdapters: CustomScalarAdapters, indent: String): String
fun <D : Operation.Data> Operation<D>.composeJsonResponse(sink: BufferedSink, data: D, customScalarAdapters: CustomScalarAdapters, indent: String)
writes a successful GraphQL Json response containing "data" to the given sink.
evaluate
Link copied to clipboard
common
fun <T : Any> BooleanExpression<T>.evaluate(block: (T) -> Boolean): Boolean
fun BooleanExpression<BTerm>.evaluate(variables: Set<String>, typename: String): Boolean
fromFile
Link copied to clipboard
fun Upload.Companion.fromFile(file: File, contentType: String): Upload
fromJson
Link copied to clipboard
common
fun <T> Adapter<T>.fromJson(string: String): T
fun <T> Adapter<T>.fromJson(bufferedSource: BufferedSource): T
fun <T> Adapter<T>.fromJson(string: String, customScalarAdapters: CustomScalarAdapters): T
fun <T> Adapter<T>.fromJson(bufferedSource: BufferedSource, customScalarAdapters: CustomScalarAdapters): T
Converts the given bufferedSource to a T
fromMap
Link copied to clipboard
common
fun <T, M : Map<String, Any?>> Adapter<T>.fromMap(map: M): T
fun <T, M : Map<String, Any?>> Adapter<T>.fromMap(map: M, customScalarAdapters: CustomScalarAdapters): T
Converts the given Map to a T
isComposite
Link copied to clipboard
common
fun CompiledNamedType.isComposite(): Boolean
keyFields
Link copied to clipboard
common
fun CompiledNamedType.keyFields(): List<String>
list
Link copied to clipboard
common
@JvmName(name = -list)
fun <T> Adapter<T>.list(): ListAdapter<T>
@JvmName(name = -list)
fun CompiledType.list(): CompiledListType
not
Link copied to clipboard
common
fun <T : Any> not(other: BooleanExpression<T>): BooleanExpression<T>
notNull
Link copied to clipboard
common
@JvmName(name = -notNull)
fun CompiledType.notNull(): CompiledNotNullType
nullable
Link copied to clipboard
common
@JvmName(name = -nullable)
fun <T : Any> Adapter<T>.nullable(): NullableAdapter<T>
obj
Link copied to clipboard
common
@JvmName(name = -obj)
fun <T> Adapter<T>.obj(buffered: Boolean = false): ObjectAdapter<T>
optional
Link copied to clipboard
common
@JvmName(name = -optional)
fun <T> Adapter<T>.optional(): OptionalAdapter<T>
or
Link copied to clipboard
common
fun <T : Any> or(vararg other: BooleanExpression<T>): BooleanExpression<T>
fun <T : Any> BooleanExpression<T>.or(vararg other: BooleanExpression<T>): BooleanExpression<T>
parseJsonData
Link copied to clipboard
common
fun <D : Operation.Data> Operation<D>.parseJsonData(string: String): D
fun <D : Operation.Data> Operation<D>.parseJsonData(source: BufferedSource): D
fun <D : Operation.Data> Operation<D>.parseJsonData(byteString: ByteString): D
fun <D : Operation.Data> Operation<D>.parseJsonData(string: String, customScalarAdapters: CustomScalarAdapters): D
fun <D : Operation.Data> Operation<D>.parseJsonData(source: BufferedSource, customScalarAdapters: CustomScalarAdapters): D
Reads only the "data" part of a GraphQL Json response
fun <D : Operation.Data> Operation<D>.parseJsonData(byteString: ByteString, customScalarAdapters: CustomScalarAdapters): D
parseJsonResponse
Link copied to clipboard
common
fun <D : Operation.Data> Operation<D>.parseJsonResponse(string: String): ApolloResponse<D>
fun <D : Operation.Data> Operation<D>.parseJsonResponse(map: Map<String, Any?>): ApolloResponse<D>
fun <D : Operation.Data> Operation<D>.parseJsonResponse(source: BufferedSource): ApolloResponse<D>
fun <D : Operation.Data> Operation<D>.parseJsonResponse(byteString: ByteString): ApolloResponse<D>
fun <D : Operation.Data> Operation<D>.parseJsonResponse(string: String, customScalarAdapters: CustomScalarAdapters): ApolloResponse<D>
fun <D : Operation.Data> Operation<D>.parseJsonResponse(map: Map<String, Any?>, customScalarAdapters: CustomScalarAdapters): ApolloResponse<D>
fun <D : Operation.Data> Operation<D>.parseJsonResponse(source: BufferedSource, customScalarAdapters: CustomScalarAdapters): ApolloResponse<D>
Reads a GraphQL Json response like below to a ApolloResponse
{
"data": ...
"errors": ...
"extensions": ...
}
fun <D : Operation.Data> Operation<D>.parseJsonResponse(byteString: ByteString, customScalarAdapters: CustomScalarAdapters): ApolloResponse<D>
possibleTypes
Link copied to clipboard
common
fun possibleTypes(vararg typenames: String): BooleanExpression<BPossibleTypes>
fun possibleTypes(allTypes: List<CompiledType>, type: CompiledNamedType): List<ObjectType>
toInput
Link copied to clipboard
common
@JvmName(name = toInputOrAbsent)
fun <T> T.toInput(): Optional<T>
@JvmName(name = toInput)
fun <T : Any> T.toInput(): Optional<T>
toJson
Link copied to clipboard
common
fun <T> Adapter<T>.toJson(value: T): String
See toJson
fun <T> Adapter<T>.toJson(sink: BufferedSink, value: T)
See toJson
fun <T> Adapter<T>.toJson(value: T, customScalarAdapters: CustomScalarAdapters, indent: String): String
Converts the given value to a Json String
fun <T> Adapter<T>.toJson(sink: BufferedSink, value: T, customScalarAdapters: CustomScalarAdapters, indent: String)
See toJson
variable
Link copied to clipboard
common
fun variable(name: String): BooleanExpression<BVariable>
variables
Link copied to clipboard
common
fun <D : Executable.Data> Executable<D>.variables(customScalarAdapters: CustomScalarAdapters): Executable.Variables
variablesJson
Link copied to clipboard
common
fun <D : Executable.Data> Executable<D>.variablesJson(customScalarAdapters: CustomScalarAdapters): String
withHttpHeader
Link copied to clipboard
common
fun <D : Operation.Data> ApolloRequest<D>.withHttpHeader(httpHeader: HttpHeader): ApolloRequest<D>
fun <D : Operation.Data> ApolloRequest<D>.withHttpHeader(name: String, value: String): ApolloRequest<D>
withHttpHeaders
Link copied to clipboard
common
fun <D : Operation.Data> ApolloRequest<D>.withHttpHeaders(httpHeaders: List<HttpHeader>): ApolloRequest<D>
withHttpMethod
Link copied to clipboard
common
fun <D : Operation.Data> ApolloRequest<D>.withHttpMethod(httpMethod: HttpMethod): ApolloRequest<D>
withSendApqExtensions
Link copied to clipboard
common
fun <D : Operation.Data> ApolloRequest<D>.withSendApqExtensions(sendApqExtensions: Boolean): ApolloRequest<D>
withSendDocument
Link copied to clipboard
common
fun <D : Operation.Data> ApolloRequest<D>.withSendDocument(sendDocument: Boolean): ApolloRequest<D>

Properties

CompiledBooleanType
Link copied to clipboard
common
val CompiledBooleanType: ScalarType
CompiledDirectiveType
Link copied to clipboard
common
val CompiledDirectiveType: ObjectType
CompiledEnumValueType
Link copied to clipboard
common
val CompiledEnumValueType: ObjectType
CompiledFieldType
Link copied to clipboard
common
val CompiledFieldType: ObjectType
CompiledFloatType
Link copied to clipboard
common
val CompiledFloatType: ScalarType
CompiledIDType
Link copied to clipboard
common
val CompiledIDType: ScalarType
CompiledInputValueType
Link copied to clipboard
common
val CompiledInputValueType: ObjectType
CompiledIntType
Link copied to clipboard
common
val CompiledIntType: ScalarType
CompiledSchemaType
Link copied to clipboard
common
val CompiledSchemaType: ObjectType
CompiledStringType
Link copied to clipboard
common
val CompiledStringType: ScalarType
CompiledTypeType
Link copied to clipboard
common
val CompiledTypeType: ObjectType
NullableAnyAdapter
Link copied to clipboard
common
val NullableAnyAdapter: NullableAdapter<Any>
NullableBooleanAdapter
Link copied to clipboard
common
val NullableBooleanAdapter: NullableAdapter<Boolean>
NullableDoubleAdapter
Link copied to clipboard
common
val NullableDoubleAdapter: NullableAdapter<Double>
NullableIntAdapter
Link copied to clipboard
common
val NullableIntAdapter: NullableAdapter<Int>
NullableStringAdapter
Link copied to clipboard
common
val NullableStringAdapter: NullableAdapter<String>
Global instances of nullable adapters for built-in scalar types