Package-level declarations

Types

Link copied to clipboard
interface Adapter<T>

An Adapter is responsible for adapting scalars between their Json and Kotlin representations.

Link copied to clipboard

This adapter is used to handle nullable fields when they are represented as Optional. null is deserialized as Optional.Absent.

Link copied to clipboard

An ApolloRequest represents a GraphQL request to execute.

Link copied to clipboard

Represents a GraphQL response or an exception if no GraphQL response is received.

Link copied to clipboard
data class BLabel(val label: String?) : BTerm

A term that comes from @defer directives and that needs to be matched against label and current JSON path

Link copied to clipboard
sealed class BooleanExpression<out T : Any>

A boolean expression

Link copied to clipboard
data class BPossibleTypes(val possibleTypes: Set<String>) : BTerm

A term that comes from a fragment type condition and that needs to be matched against __typename

Link copied to clipboard
sealed class BTerm

A generic term in a BooleanExpression

Link copied to clipboard
interface BuilderFactory<out T>
Link copied to clipboard
class BuilderProperty<T>(val adapter: Adapter<T>)

A property delegate that stores the given property as it would be serialized in a Json This is needed in Data Builders because the serializer only work from Json

Link copied to clipboard
interface BuilderScope
Link copied to clipboard
data class BVariable(val name: String) : BTerm

A term that comes from @include/@skip or @defer directives and that needs to be matched against operation variables

Link copied to clipboard
Link copied to clipboard
data class CompiledCondition(val name: String, val inverted: Boolean)
Link copied to clipboard

A compiled field from a GraphQL operation

Link copied to clipboard

A compiled inline fragment or fragment spread

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
sealed class CompiledSelection
Link copied to clipboard
sealed class CompiledType
Link copied to clipboard
typealias CompiledValue = Any?

The Kotlin representation of a GraphQL value

Link copied to clipboard
class CompiledVariable(val name: String)

The Kotlin representation of a GraphQL variable value

Link copied to clipboard

A wrapper around a MapAdapter> used to retrieve custom scalar adapters at runtime.

Link copied to clipboard
class CustomScalarType(val name: String, val className: String) : CompiledNamedType

A GraphQL scalar type that is mapped to a Kotlin. This is named "Custom" for historical reasons but is also used for builtin scalars

Link copied to clipboard

A replica of Apollo Android v2's CustomTypeAdapter, to ease migration from v2 to v3.

Link copied to clipboard

A FakeResolver that generates:

Link copied to clipboard

A default Upload that can upload from a wide variety of content

Link copied to clipboard
data class DeferredFragmentIdentifier(val path: List<Any>, val label: String?)
Link copied to clipboard
class EnumType(val name: String, val values: List<String>) : CompiledNamedType
Link copied to clipboard
class Error @ApolloDeprecatedSince(version = ApolloDeprecatedSince.Version.v4_0_0) constructor(val message: String, val locations: List<Error.Location>?, val path: List<Any>?, val extensions: Map<String, Any?>?, val nonStandardFields: Map<String, Any?>?)

Represents an error response returned from the GraphQL server See https://spec.graphql.org/draft/#sec-Errors.Error-result-format

Link copied to clipboard

Base interface for Operation and Fragment that have a Adapter and Variables.

Link copied to clipboard

A context of GraphQL operation execution, represented as a set of Key keys and corresponding Element values.

Link copied to clipboard
Link copied to clipboard
interface FakeResolver

Provides fakes values for Data builders

Link copied to clipboard
Link copied to clipboard
sealed interface FieldResult<out V>
Link copied to clipboard

Base interface for a fragment implementation. Fragments do not have variables per the GraphQL spec but they are inferred from arguments and used when reading the cache See https://github.com/graphql/graphql-spec/issues/204 for a proposal to add fragment arguments

Link copied to clipboard

A helper class to make it easier to build Maps from the java codegen

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
class ListAdapter<T>(wrappedAdapter: Adapter<T>) : Adapter<List<@JvmSuppressWildcards T>>

This file contains a list of Adapter for standard types

Link copied to clipboard
Link copied to clipboard

Type safe representation of a GraphQL mutation.

Link copied to clipboard
class NullableAdapter<T : Any>(wrappedAdapter: Adapter<T>) : Adapter<@JvmSuppressWildcards T?>
Link copied to clipboard
class ObjectAdapter<T>(wrappedAdapter: Adapter<T>, buffered: Boolean) : Adapter<@JvmSuppressWildcards T>
Link copied to clipboard
abstract class ObjectBuilder<out T : Map<String, Any?>>(val customScalarAdapters: CustomScalarAdapters) : BuilderScope
Link copied to clipboard
abstract class ObjectMap(__fields: Map<String, Any?>) : Map<String, Any?>
Link copied to clipboard
Link copied to clipboard

Represents a GraphQL operation (mutation, query or subscription).

Link copied to clipboard
sealed class Optional<out V>

A sealed class that can either be Present or Absent

Link copied to clipboard
Link copied to clipboard

PresentAdapter can only express something that's present. Absent values are handled outside the adapter.

Link copied to clipboard
interface Query<D : Query.Data> : Operation<D>

Type safe representation of a GraphQL query.

Link copied to clipboard

TODO v4: remove (see also CustomScalarType above

Link copied to clipboard

Type safe representation of a GraphQL subscription.

Link copied to clipboard
class UnionType(val name: String, val members: ObjectType) : CompiledNamedType
Link copied to clipboard
interface Upload

A class that represents a file upload in a multipart upload See https://github.com/jaydenseric/graphql-multipart-request-spec

Link copied to clipboard

The variables as a Json representation. If some

Properties

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

An Adapter that converts to/from a Float Floats are not part of the GraphQL spec but this can be used in custom scalars

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

An Adapter that converts to/from a Long Longs are not part of the GraphQL spec but this can be used in custom scalars

Link copied to clipboard
Link copied to clipboard

Functions

Link copied to clipboard
fun <T> adaptValue(adapter: Adapter<T>, value: T): Any?
Link copied to clipboard
fun <T : Any> and(vararg other: BooleanExpression<T>): BooleanExpression<T>
Link copied to clipboard
actual inline fun <T> Any.apolloUnsafeCast(): T
expect inline fun <T> Any.apolloUnsafeCast(): T

Uses unsafeCast on JS or a regular as unsafe cast on other platforms.

actual inline fun <T> Any.apolloUnsafeCast(): T
actual inline fun <T> Any.apolloUnsafeCast(): T
actual inline fun <T> Any.apolloUnsafeCast(): T
actual inline fun <T> Any.apolloUnsafeCast(): T
Link copied to clipboard
@JvmName(name = "-array")
inline fun <T> Adapter<T>.array(): Adapter<Array<T>>

Note that Arrays require their type to be known at compile time, so we construct an anonymous object with reference to function with reified type parameters as a workaround.

Link copied to clipboard
fun assertOneOf(vararg args: Optional<*>)
fun assertOneOf(vararg args: Optional<out Optional<*>>)
Link copied to clipboard
fun <T> buildData(adapter: Adapter<T>, selections: List<CompiledSelection>, typename: String, map: Map<String, Any?>, resolver: FakeResolver, customScalarAdapters: CustomScalarAdapters): T
fun <T, Builder : ObjectBuilder<*>> buildData(builderFactory: BuilderFactory<Builder>, block: Builder.() -> Unit, adapter: Adapter<T>, selections: List<CompiledSelection>, typename: String, resolver: FakeResolver, customScalarAdapters: CustomScalarAdapters): T
Link copied to clipboard
fun Builder(customScalarAdapters: CustomScalarAdapters): BuilderScope
Link copied to clipboard
@JvmName(name = "-catchToNull")
fun <T> Adapter<T>.catchToNull(): Adapter<T?>
Link copied to clipboard
@JvmName(name = "-catchToResult")
fun <T> Adapter<T>.catchToResult(): Adapter<FieldResult<T>>
Link copied to clipboard
fun checkFieldNotMissing(value: Any?, name: String)

Helper function for the Java codegen

Link copied to clipboard
fun <D : Executable.Data> Executable<D>.composeData(jsonWriter: JsonWriter, customScalarAdapters: CustomScalarAdapters, value: D)
Link copied to clipboard
fun <D : Operation.Data> Operation<D>.composeJsonRequest(jsonWriter: JsonWriter, customScalarAdapters: CustomScalarAdapters = CustomScalarAdapters.Empty)

Reads a GraphQL Json response like below to a ApolloResponse

Link copied to clipboard
fun <D : Operation.Data> Operation<D>.composeJsonResponse(data: D, customScalarAdapters: CustomScalarAdapters = CustomScalarAdapters.Empty): String

fun <D : Operation.Data> Operation<D>.composeJsonResponse(jsonWriter: JsonWriter, data: D, customScalarAdapters: CustomScalarAdapters = CustomScalarAdapters.Empty)

writes a successful GraphQL Json response containing "data" to the given sink.

Link copied to clipboard
inline fun <T> Any.defaultApolloUnsafeCast(): T
Link copied to clipboard
@JvmName(name = "-errorAware")
fun <T> Adapter<T>.errorAware(): Adapter<T>
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Returns the Set of boolean variables that are false either explicitly or because there is a default value

Link copied to clipboard
fun <V> FieldResult<V>.getOrElse(fallback: V): V

fun <V> Optional<V>.getOrElse(fallback: V): V

Returns the value if this Optional is Present or fallback else.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
fun label(label: String? = null): BooleanExpression<BLabel>
Link copied to clipboard
@JvmName(name = "-list")
fun <T> Adapter<T>.list(): ListAdapter<T>
@JvmName(name = "-list")
fun CompiledType.list(): CompiledListType
Link copied to clipboard
fun <V, R> Optional<V>.map(mapper: (V) -> R): Optional<R>
Link copied to clipboard
fun missingField(jsonReader: JsonReader, name: String): Nothing

Helper function for the Kotlin codegen

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
@JvmName(name = "-nullable")
fun <T : Any> Adapter<T>.nullable(): NullableAdapter<T>
Link copied to clipboard
@JvmName(name = "-obj")
fun <T> Adapter<T>.obj(buffered: Boolean = false): ObjectAdapter<T>
Link copied to clipboard
@JvmName(name = "-optional")
fun <T> Adapter<T>.optional(): PresentAdapter<T>
Link copied to clipboard
fun <T : Any> or(vararg other: BooleanExpression<T>): BooleanExpression<T>
Link copied to clipboard
fun <D : Executable.Data> Executable<D>.parseData(jsonReader: JsonReader, customScalarAdapters: CustomScalarAdapters = CustomScalarAdapters.Empty, falseVariables: Set<String>? = null, deferredFragmentIds: Set<DeferredFragmentIdentifier>? = null, errors: List<Error>? = null): D?
Link copied to clipboard
fun <D : Operation.Data> Operation<D>.parseJsonResponse(jsonReader: JsonReader, customScalarAdapters: CustomScalarAdapters = CustomScalarAdapters.Empty, deferredFragmentIdentifiers: Set<DeferredFragmentIdentifier>? = null): ApolloResponse<D>

Reads a GraphQL Json response to a ApolloResponse. GraphQL Json responses look like so:

Link copied to clipboard
fun <D : Operation.Data> Operation<D>.parseResponse(jsonReader: JsonReader, requestUuid: Uuid? = null, customScalarAdapters: CustomScalarAdapters = CustomScalarAdapters.Empty, deferredFragmentIdentifiers: Set<DeferredFragmentIdentifier>? = null): ApolloResponse<D>

Reads a GraphQL Json response like below to a ApolloResponse. GraphQL Json responses look like so:

fun <D : Operation.Data> JsonReader.parseResponse(operation: Operation<D>, requestUuid: Uuid? = null, customScalarAdapters: CustomScalarAdapters = CustomScalarAdapters.Empty, deferredFragmentIdentifiers: Set<DeferredFragmentIdentifier>? = null): ApolloResponse<D>

Reads a ApolloResponse from this. The caller is responsible for closing this.

Link copied to clipboard

Returns all objects that implement type

Link copied to clipboard
@JvmName(name = "-present")
fun <T> Adapter<T>.present(): PresentAdapter<T>
Link copied to clipboard
fun <D : Operation.Data> JsonReader.toApolloResponse(operation: Operation<D>, requestUuid: Uuid? = null, customScalarAdapters: CustomScalarAdapters = CustomScalarAdapters.Empty, deferredFragmentIdentifiers: Set<DeferredFragmentIdentifier>? = null): ApolloResponse<D>

Reads a single ApolloResponse from this. Returns an error response if this contains more than one JSON response or trailing tokens. toApolloResponse takes ownership and closes this.

Link copied to clipboard
fun Operation.Data.toJson(customScalarAdapters: CustomScalarAdapters = CustomScalarAdapters.Empty): String

Serializes the given Data to a String.

expect fun Operation.Data.toJson(jsonWriter: JsonWriter, customScalarAdapters: CustomScalarAdapters = CustomScalarAdapters.Empty)

Serializes the given Data to the given JsonWriter.

Link copied to clipboard
@JvmName(name = "-toJson")
fun <T> Adapter<T>.toJsonString(value: T, customScalarAdapters: CustomScalarAdapters = CustomScalarAdapters.Empty, indent: String? = null): String
fun <Error class: unknown class>.toJsonString(customScalarAdapters: <Error class: unknown class> = CustomScalarAdapters.Empty, indent: String? = null): String

Serializes the given Data to a string.

Link copied to clipboard
fun Operation.Data.toResponseJson(customScalarAdapters: CustomScalarAdapters = CustomScalarAdapters.Empty): String

Serializes the given Data to a successful GraphQL response:

Link copied to clipboard
fun Path.toUpload(contentType: String, fileSystem: FileSystem = FileSystem.SYSTEM): <Error class: unknown class>
fun File.toUpload(contentType: String): <Error class: unknown class>
Link copied to clipboard
Link copied to clipboard

Returns a map of the variables as they would be sent over the wire. Use this to construct your own HTTP requests

fun <D : Executable.Data> Executable<D>.variables(customScalarAdapters: CustomScalarAdapters, withDefaultValues: Boolean): Executable.Variables
Link copied to clipboard

Returns the variables as they would be sent over the wire. Use this to construct your own HTTP requests