OperationRef

interface OperationRef<Data : Any?, Variables : Any?>

Known direct subclasses
MutationRef

A specialization of OperationRef for mutation operations.

QueryRef

A specialization of OperationRef for query operations.


Information about a Firebase Data Connect "operation" (i.e. a query or mutation).

OperationRef has two inheritors: QueryRef for queries and MutationRef for mutations. OperationRef merely serves to provide a common interface for the parts of queries and mutations that are shared.

Safe for Concurrent Use

All methods and properties of OperationRef are thread-safe and may be safely called and/or accessed concurrently from multiple threads and/or coroutines.

Not Stable for Inheritance

The OperationRef interface is not stable for inheritance in third-party libraries, as new methods might be added to this interface or contracts of the existing methods can be changed.

Summary

Public functions

OperationRef<Data, Variables>
@ExperimentalFirebaseDataConnect
copy(
    operationName: String,
    variables: Variables,
    dataDeserializer: DeserializationStrategy<Data>,
    variablesSerializer: SerializationStrategy<Variables>,
    callerSdkType: FirebaseDataConnect.CallerSdkType,
    dataSerializersModule: SerializersModule?,
    variablesSerializersModule: SerializersModule?
)

Creates and returns a new object that is a copy of this object, but with the properties whose names corresponding to the given arguments changed to the respective argument's value.

operator Boolean
equals(other: Any?)

Compares this object with another object for equality.

suspend OperationResult<Data, Variables>

Executes this operation and returns the result.

Int

Calculates and returns the hash code for this object.

String

Returns a string representation of this object, useful for debugging.

OperationRef<NewData, Variables>
@ExperimentalFirebaseDataConnect
<NewData : Any?> withDataDeserializer(
    dataDeserializer: DeserializationStrategy<NewData>,
    dataSerializersModule: SerializersModule?
)

Creates and returns a new object that is a copy of this object, just like copy, except that the dataDeserializer can be a different type than Data.

OperationRef<Data, NewVariables>
@ExperimentalFirebaseDataConnect
<NewVariables : Any?> withVariablesSerializer(
    variables: NewVariables,
    variablesSerializer: SerializationStrategy<NewVariables>,
    variablesSerializersModule: SerializersModule?
)

Creates and returns a new object that is a copy of this object, just like copy, except that the variables and variablesSerializer can be a different type than Variables.

Public properties

FirebaseDataConnect.CallerSdkType

The FirebaseDataConnect.CallerSdkType that will be associated with all operations performed by this object for analytics purposes.

FirebaseDataConnect

The FirebaseDataConnect with which this object is associated.

DeserializationStrategy<Data>

The deserializer to use to deserialize the response data for this operation.

SerializersModule?

A SerializersModule to use when decoding the response data using dataDeserializer.

String

The name of the operation, as defined in GraphQL.

Variables

The variables for the operation.

SerializationStrategy<Variables>

The serializer to use to serialize the variables for this operation.

SerializersModule?

A SerializersModule to use when encoding the variables using variablesSerializer.

Public functions

copy

@ExperimentalFirebaseDataConnect
fun copy(
    operationName: String = this.operationName,
    variables: Variables = this.variables,
    dataDeserializer: DeserializationStrategy<Data> = this.dataDeserializer,
    variablesSerializer: SerializationStrategy<Variables> = this.variablesSerializer,
    callerSdkType: FirebaseDataConnect.CallerSdkType = this.callerSdkType,
    dataSerializersModule: SerializersModule? = this.dataSerializersModule,
    variablesSerializersModule: SerializersModule? = this.variablesSerializersModule
): OperationRef<Data, Variables>

Creates and returns a new object that is a copy of this object, but with the properties whose names corresponding to the given arguments changed to the respective argument's value.

This function is essentially the same as the copy() method that is generated by the Kotlin compiler for data class classes.

equals

operator fun equals(other: Any?): Boolean

Compares this object with another object for equality.

Parameters
other: Any?

The object to compare to this for equality.

Returns
Boolean

true if, and only if, the other object is an instance of the same implementation of OperationRef whose public properties compare equal using the == operator to the corresponding properties of this object.

execute

suspend fun execute(): OperationResult<Data, Variables>

Executes this operation and returns the result.

An exception is thrown if the operation fails for any reason, including

  • The FirebaseDataConnect object has been closed.

  • The Firebase Data Connect server is unreachable.

  • Authentication with the Firebase Data Connect server fails.

  • The variables are rejected by the Firebase Data Connect server.

  • The data response sent by the Firebase Data Connect server cannot be deserialized.

hashCode

fun hashCode(): Int

Calculates and returns the hash code for this object.

The hash code is not guaranteed to be stable across application restarts.

Returns
Int

the hash code for this object, that incorporates the values of this object's public properties.

toString

fun toString(): String

Returns a string representation of this object, useful for debugging.

The string representation is not guaranteed to be stable and may change without notice at any time. Therefore, the only recommended usage of the returned string is debugging and/or logging. Namely, parsing the returned string or storing the returned string in non-volatile storage should generally be avoided in order to be robust in case that the string representation changes.

Returns
String

a string representation of this object, which includes the class name and the values of all public properties.

withDataDeserializer

@ExperimentalFirebaseDataConnect
fun <NewData : Any?> withDataDeserializer(
    dataDeserializer: DeserializationStrategy<NewData>,
    dataSerializersModule: SerializersModule? = this.dataSerializersModule
): OperationRef<NewData, Variables>

Creates and returns a new object that is a copy of this object, just like copy, except that the dataDeserializer can be a different type than Data.

withVariablesSerializer

@ExperimentalFirebaseDataConnect
fun <NewVariables : Any?> withVariablesSerializer(
    variables: NewVariables,
    variablesSerializer: SerializationStrategy<NewVariables>,
    variablesSerializersModule: SerializersModule? = this.variablesSerializersModule
): OperationRef<Data, NewVariables>

Creates and returns a new object that is a copy of this object, just like copy, except that the variables and variablesSerializer can be a different type than Variables.

Public properties

callerSdkType

val callerSdkTypeFirebaseDataConnect.CallerSdkType

The FirebaseDataConnect.CallerSdkType that will be associated with all operations performed by this object for analytics purposes.

dataConnect

val dataConnectFirebaseDataConnect

The FirebaseDataConnect with which this object is associated.

dataDeserializer

val dataDeserializerDeserializationStrategy<Data>

The deserializer to use to deserialize the response data for this operation.

Typically, the deserializer will be generated by Kotlin's serialization plugin for a class annotated with kotlinx.serialization.Serializable.

For example, a query defined as

query GetPersonById($id: UUID!) { person(id: $id) { name age } }

could define its data class could as follows:

@Serializable
data
class GetPersonByIdData(val person: Person?) {
@Serializable
data class Person(val name: String, val age: Int?)
}

and the deserializer could be retrieved by calling kotlinx.serialization.serializer as follows:

serializer<GetPersonByIdData>()

dataSerializersModule

val dataSerializersModuleSerializersModule?

A SerializersModule to use when decoding the response data using dataDeserializer. May be null, to not use a SerializersModule.

operationName

val operationNameString

The name of the operation, as defined in GraphQL.

For example, a query defined as

query GetPersonById($id: UUID!) { person(id: $id) { name age } }

would have the operation name "GetPersonById" and a mutation defined as

mutation InsertPerson($name: String!, $age: Int) {...}

would have the operation name "InsertPerson"

variables

val variables: Variables

The variables for the operation.

The variables will be serialized using variablesSerializer and must produce a map whose keys are strings whose values are the names of the variables as defined in GraphQL, and whose values are the corresponding values.

For example, a query defined as

query GetPersonById($id: UUID!) { person(id: $id) { name age } }

would have a variable named "id" whose value is a java.util.UUID instance and a mutation defined as

mutation InsertPerson($name: String!, $age: Int) {...}

would have two variables named "name" and "age" whose values are String and Int? values, respectively.

variablesSerializer

val variablesSerializerSerializationStrategy<Variables>

The serializer to use to serialize the variables for this operation.

Typically, the serializer will be generated by Kotlin's serialization plugin for a class annotated with kotlinx.serialization.Serializable.

For example, a mutation defined as

mutation InsertPerson($name: String!, $age: Int) {...}

could define its variables class could as follows:

@Serializable
data
class InsertPersonVariables(val name: String, val age: Int?)

and the serializer could be retrieved by calling kotlinx.serialization.serializer as follows:

serializer<InsertPersonVariables>()

variablesSerializersModule

val variablesSerializersModuleSerializersModule?

A SerializersModule to use when encoding the variables using variablesSerializer. May be null, to not use a SerializersModule.