Package com.apollographql.apollo3.api

Types

Link copied to clipboard
interface Adapter<T>

An Adapter is responsible for adapting Kotlin-generated GraphQL types to/from their Json representation.

Link copied to clipboard
class AdapterContext
Link copied to clipboard
class ApolloOptionalAdapter<T>(wrappedAdapter: Adapter<T>) : Adapter<Optional<@JvmSuppressWildcards T>>

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

Link copied to clipboard
class ApolloRequest<D : Operation.Data> : ExecutionOptions

A GraphQL request to execute. Execution can be customized with executionContext

Link copied to clipboard
class ApolloResponse<D : Operation.Data>

Represents a GraphQL response. GraphQL responses can be be partial responses so it is valid to have both data != null and errors

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
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, val defaultValue: Boolean?) : BTerm

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

Link copied to clipboard
class CompiledArgument

The Kotlin representation of a GraphQL argument

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

A compiled field from a GraphQL operation

Link copied to clipboard
class CompiledFragment : CompiledSelection

A compiled inline fragment or fragment spread

Link copied to clipboard
class CompiledListType(val ofType: CompiledType) : CompiledType
Link copied to clipboard
sealed class CompiledNamedType : CompiledType
Link copied to clipboard
class CompiledNotNullType(val ofType: CompiledType) : CompiledType
Link copied to clipboard
sealed class CompiledSelection
Link copied to clipboard
sealed class CompiledType
Link copied to clipboard
class CompiledVariable(val name: String)

The Kotlin representation of a GraphQL variable value

Link copied to clipboard
class CustomScalarAdapters : ExecutionContext.Element

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
interface CustomTypeAdapter<T>

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

Link copied to clipboard
sealed class CustomTypeValue<T>

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

Link copied to clipboard
open class DefaultFakeResolver(types: List<CompiledNamedType>) : FakeResolver

A FakeResolver that generates:

Link copied to clipboard
class DefaultUpload : Upload

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(    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
interface Executable<D : Executable.Data>

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

Link copied to clipboard
interface ExecutionContext

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

Link copied to clipboard
interface ExecutionOptions
Link copied to clipboard
interface FakeResolver

Provides fakes values for Data builders

Link copied to clipboard
class FakeResolverContext
Link copied to clipboard
interface Fragment<D : Fragment.Data> : Executable<D>

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
class ImmutableMapBuilder<K, V>

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

Link copied to clipboard
class Input
Link copied to clipboard
class InputObjectType(val name: String) : CompiledNamedType
Link copied to clipboard
class InterfaceType : CompiledNamedType
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
interface MutableExecutionOptions<T> : ExecutionOptions
Link copied to clipboard
interface Mutation<D : Mutation.Data> : Operation<D>

Represents a GraphQL mutation operation that will be sent to the server.

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(val customScalarAdapters: CustomScalarAdapters) : BuilderScope
Link copied to clipboard
abstract class ObjectMap(__fields: Map<String, Any?>) : Map<String, Any?>
Link copied to clipboard
class ObjectType : CompiledNamedType
Link copied to clipboard
interface Operation<D : Operation.Data> : Executable<D>

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
class OptionalAdapter<T>(wrappedAdapter: Adapter<T>) : Adapter<Optional.Present<@JvmSuppressWildcards T>>
Link copied to clipboard
class PresentAdapter<T>(wrappedAdapter: Adapter<T>) : Adapter<Optional.Present<@JvmSuppressWildcards T>>

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

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

Represents a GraphQL query that will be sent to the server.

Link copied to clipboard
Link copied to clipboard
typealias Response<D> = ApolloResponse<D>
Link copied to clipboard
class ScalarType(val name: String) : CompiledNamedType

TODO v4: remove (see also CustomScalarType above

Link copied to clipboard
class ScalarTypeAdapters(val customAdapters: Map<CustomScalarType, CustomTypeAdapter<*>>)

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

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

Represents 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

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>
fun <T : Any> BooleanExpression<T>.and(vararg other: BooleanExpression<T>): BooleanExpression<T>
Link copied to clipboard
fun <T> buildData(    adapter: Adapter<T>,     selections: List<CompiledSelection>,     typename: String,     map: Map<String, Any?>,     resolver: FakeResolver,     customScalarAdapters: CustomScalarAdapters): T
Link copied to clipboard
fun Builder(customScalarAdapters: CustomScalarAdapters): BuilderScope
Link copied to clipboard
fun <T> buildFragmentData(    adapter: Adapter<T>,     selections: List<CompiledSelection>,     typename: String,     block: Any? = null,     resolver: FakeResolver,     type: CompiledType,     customScalarAdapters: CustomScalarAdapters): T
Link copied to clipboard
fun checkFieldNotMissing(value: Any?, name: String)

Helper function for the JavaCodegen

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(    jsonWriter: JsonWriter,     data: D,     customScalarAdapters: CustomScalarAdapters = CustomScalarAdapters.Empty)

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

Link copied to clipboard
fun <T : Any> BooleanExpression<T>.containsPossibleTypes(): Boolean
Link copied to clipboard
Link copied to clipboard
fun create(mimetype: String, filePath: String): Upload
Link copied to clipboard
fun <T : Any> BooleanExpression<T>.evaluate(block: (T) -> Boolean): Boolean
fun BooleanExpression<BTerm>.evaluate(variables: Set<String>, typename: String?): Boolean
fun BooleanExpression<BTerm>.evaluate(    variables: Set<String>,     typename: String?,     adapterContext: AdapterContext,     path: List<Any>?): Boolean
Link copied to clipboard
fun <T : Any, U : Any> BooleanExpression<T>.firstElementOfType(type: KClass<U>): U?
Link copied to clipboard
fun CompiledNamedType.isComposite(): Boolean
Link copied to clipboard
fun CompiledNamedType.keyFields(): List<String>
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 <T : Any> not(other: BooleanExpression<T>): BooleanExpression<T>
Link copied to clipboard
@JvmName(name = "-notNull")
fun CompiledType.notNull(): CompiledNotNullType
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>
fun <T : Any> BooleanExpression<T>.or(vararg other: BooleanExpression<T>): BooleanExpression<T>
Link copied to clipboard
fun <D : Operation.Data> Operation<D>.parseJsonResponse(jsonReader: JsonReader, customScalarAdapters: CustomScalarAdapters = CustomScalarAdapters.Empty): ApolloResponse<D>

Reads a GraphQL Json response like below to a ApolloResponse

fun <D : Operation.Data> Operation<D>.parseJsonResponse(json: String, customScalarAdapters: CustomScalarAdapters = CustomScalarAdapters.Empty): ApolloResponse<D>
Link copied to clipboard
fun possibleTypes(vararg typenames: String): BooleanExpression<BPossibleTypes>

fun possibleTypes(allTypes: List<CompiledType>, type: CompiledNamedType): List<ObjectType>

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 resolveVariables(value: Any?, variables: Executable.Variables): Any?

Resolve all variables that may be contained inside value

Link copied to clipboard
fun <T> T.toInput(): Optional<T>
fun <T : Any> T.toInput(): Optional<T>
Link copied to clipboard
actual fun Operation.Data.toJson(jsonWriter: JsonWriter, customScalarAdapters: CustomScalarAdapters)
fun Operation.Data.toJson(customScalarAdapters: CustomScalarAdapters = CustomScalarAdapters.Empty): String
expect fun Operation.Data.toJson(jsonWriter: JsonWriter, customScalarAdapters: CustomScalarAdapters = CustomScalarAdapters.Empty)
actual fun Operation.Data.toJson(jsonWriter: JsonWriter, customScalarAdapters: CustomScalarAdapters)
actual fun Operation.Data.toJson(jsonWriter: JsonWriter, customScalarAdapters: CustomScalarAdapters)
actual fun Operation.Data.toJson(jsonWriter: JsonWriter, customScalarAdapters: CustomScalarAdapters)
Link copied to clipboard
@JvmName(name = "-toJson")
fun <T> Adapter<T>.toJsonString(    value: T,     customScalarAdapters: CustomScalarAdapters = CustomScalarAdapters.Empty,     indent: String? = null): String
fun Operation.Data.toJsonString(customScalarAdapters: CustomScalarAdapters = CustomScalarAdapters.Empty, indent: String? = null): String
Link copied to clipboard
fun Operation.Data.toResponseJson(customScalarAdapters: CustomScalarAdapters = CustomScalarAdapters.Empty): String
Link copied to clipboard
fun Path.toUpload(contentType: String, fileSystem: FileSystem = systemFileSystem): Upload
fun File.toUpload(contentType: String): DefaultUpload
Link copied to clipboard
fun variable(name: String): BooleanExpression<BVariable>
Link copied to clipboard
fun <D : Executable.Data> Executable<D>.variables(customScalarAdapters: CustomScalarAdapters): Executable.Variables
fun <D : Executable.Data> Executable<D>.variables(customScalarAdapters: CustomScalarAdapters, withDefaultBooleanValues: Boolean): Executable.Variables
Link copied to clipboard
fun <D : Executable.Data> Executable<D>.variablesJson(customScalarAdapters: CustomScalarAdapters): String
Link copied to clipboard

Properties

Link copied to clipboard
val AnyAdapter: Adapter<Any>
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
val BooleanAdapter: Adapter<Boolean>
Link copied to clipboard
Link copied to clipboard
val CompiledDirectiveType: ObjectType
Link copied to clipboard
val CompiledEnumValueType: ObjectType
Link copied to clipboard
val CompiledFieldType: ObjectType
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
val CompiledInputValueType: ObjectType
Link copied to clipboard
Link copied to clipboard
val CompiledSchemaType: ObjectType
Link copied to clipboard
Link copied to clipboard
val CompiledTypeType: ObjectType
Link copied to clipboard
val DoubleAdapter: Adapter<Double>
Link copied to clipboard
val 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

Link copied to clipboard
val GlobalBuilder: BuilderScope
Link copied to clipboard
val IntAdapter: Adapter<Int>
Link copied to clipboard
val 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 scalars

Link copied to clipboard
val NullableAnyAdapter: NullableAdapter<Any>
Link copied to clipboard
val NullableBooleanAdapter: NullableAdapter<Boolean>
Link copied to clipboard
val NullableDoubleAdapter: NullableAdapter<Double>
Link copied to clipboard
val NullableIntAdapter: NullableAdapter<Int>
Link copied to clipboard
val NullableStringAdapter: NullableAdapter<String>
Link copied to clipboard
val StringAdapter: Adapter<String>
Link copied to clipboard
val UploadAdapter: Adapter<Upload>