OperationRef

interfaceOperationRef<Data : Any?, Variables : Any?>

Known direct subclasses
MutationRef

A specialization ofOperationRef formutation operations.

QueryRef

A specialization ofOperationRef forquery operations.


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

OperationRef has two inheritors:QueryRef for queries andMutationRef 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 ofOperationRef are thread-safe and may be safely called and/or accessed concurrently from multiple threads and/or coroutines.

Not stable for inheritance

TheOperationRef interface isnot 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 acopy of this object, but with the properties whose names corresponding to the given arguments changed to the respective argument's value.

operatorBoolean
equals(other: Any?)

Compares this object with another object for equality.

suspendOperationResult<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 acopy of this object, just likecopy, except that thedataDeserializer can be a different type thanData.

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

Creates and returns a new object that is acopy of this object, just likecopy, except that thevariables andvariablesSerializer can be a different type thanVariables.

Public properties

FirebaseDataConnect.CallerSdkType

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

FirebaseDataConnect

TheFirebaseDataConnect with which this object is associated.

DeserializationStrategy<Data>

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

SerializersModule?

ASerializersModule to use when decoding the response data usingdataDeserializer.

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?

ASerializersModule to use when encoding the variables usingvariablesSerializer.

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 acopy 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 thecopy() method that is generated by the Kotlin compiler fordata 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 ofOperationRef 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

  • TheFirebaseDataConnect 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 isnot 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 isnot 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 acopy of this object, just likecopy, except that thedataDeserializer can be a different type thanData.

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 acopy of this object, just likecopy, except that thevariables andvariablesSerializer can be a different type thanVariables.

Public properties

callerSdkType

val callerSdkTypeFirebaseDataConnect.CallerSdkType

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

dataConnect

val dataConnectFirebaseDataConnect

TheFirebaseDataConnect 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 withkotlinx.serialization.Serializable.

For example, a query defined as

queryGetPersonById($id:UUID!){person(id:$id){nameage}}

could define its data class as follows:

@Serializable
data
classGetPersonByIdData(valperson:Person?){
@Serializable
dataclassPerson(valname:String,valage:Int?)
}

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

serializer<GetPersonByIdData>()

dataSerializersModule

val dataSerializersModuleSerializersModule?

ASerializersModule to use when decoding the response data usingdataDeserializer. May benull, to not use aSerializersModule.

operationName

val operationNameString

The name of the operation, as defined in GraphQL.

For example, a query defined as

queryGetPersonById($id:UUID!){person(id:$id){nameage}}

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

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

would have the operation name"InsertPerson"

variables

val variables: Variables

The variables for the operation.

The variables will be serialized usingvariablesSerializer 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

queryGetPersonById($id:UUID!){person(id:$id){nameage}}

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

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

would have two variables named"name" and"age" whose values areString andInt? 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 withkotlinx.serialization.Serializable.

For example, a mutation defined as

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

could define its variables class as follows:

@Serializable
data
classInsertPersonVariables(valname:String,valage:Int?)

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

serializer<InsertPersonVariables>()

variablesSerializersModule

val variablesSerializersModuleSerializersModule?

ASerializersModule to use when encoding the variables usingvariablesSerializer. May benull, to not use aSerializersModule.

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-10-09 UTC.