rpc call returns a serialization error in kotlin
Please Help. This is the error message iam getting
AvailableItemsRepoImpl$searchAvailableItem$2' is not registered for polymorphic serialization in the scope of 'Function0'.
To be registered automatically, class AvailableItemsRepoImpl$searchAvailableItem$2' has to be '@Serializable', and the base class 'Function0' has to be sealed and '@Serializable'.
Alternatively, register the serializer for 'class AvailableItemsRepoImpl$searchAvailableItem$2' explicitly in a corresponding SerializersModule.
And this is how i have structured my classes
@Serializable
sealed interface AvailableItemsRepo {
suspend fun searchAvailableItem(query:String):List<AvailableItem>
}
@Serializable
class AvailableItemsRepoImpl @Inject constructor (val client: SupabaseClient) :
AvailableItemsRepo {
override suspend fun searchAvailableItem(query: String): List<AvailableItem> {
return client.postgrest.rpc(
function = "available_phone",
parameters = {
query
}
).decodeList<AvailableItem>().reversed()
}
}
iam using this plugin in gradle
id("org.jetbrains.kotlin.plugin.serialization") version "1.9.0"
Please any help will be greatly appreciated as I have been on this for days. Thanks in advance
AvailableItemsRepoImpl$searchAvailableItem$2' is not registered for polymorphic serialization in the scope of 'Function0'.
To be registered automatically, class AvailableItemsRepoImpl$searchAvailableItem$2' has to be '@Serializable', and the base class 'Function0' has to be sealed and '@Serializable'.
Alternatively, register the serializer for 'class AvailableItemsRepoImpl$searchAvailableItem$2' explicitly in a corresponding SerializersModule.
And this is how i have structured my classes
@Serializable
sealed interface AvailableItemsRepo {
suspend fun searchAvailableItem(query:String):List<AvailableItem>
}
@Serializable
class AvailableItemsRepoImpl @Inject constructor (val client: SupabaseClient) :
AvailableItemsRepo {
override suspend fun searchAvailableItem(query: String): List<AvailableItem> {
return client.postgrest.rpc(
function = "available_phone",
parameters = {
query
}
).decodeList<AvailableItem>().reversed()
}
}
iam using this plugin in gradle
id("org.jetbrains.kotlin.plugin.serialization") version "1.9.0"
Please any help will be greatly appreciated as I have been on this for days. Thanks in advance