mirror of
https://github.com/Suwayomi/TachideskJUI.git
synced 2025-12-13 08:12:02 +01:00
Preparation for GraphQL
This commit is contained in:
@@ -61,6 +61,8 @@ kotlin {
|
|||||||
api(libs.ktor.websockets)
|
api(libs.ktor.websockets)
|
||||||
api(libs.okio)
|
api(libs.okio)
|
||||||
api(libs.dateTime)
|
api(libs.dateTime)
|
||||||
|
api(libs.apollo.runtime)
|
||||||
|
api(libs.apollo.engine.ktor)
|
||||||
api(projects.core)
|
api(projects.core)
|
||||||
api(projects.i18n)
|
api(projects.i18n)
|
||||||
api(projects.domain)
|
api(projects.domain)
|
||||||
@@ -124,5 +126,7 @@ android {
|
|||||||
apollo {
|
apollo {
|
||||||
service("service") {
|
service("service") {
|
||||||
packageName.set("ca.gosyer.jui.data.graphql")
|
packageName.set("ca.gosyer.jui.data.graphql")
|
||||||
|
generateMethods.set(listOf("equalsHashCode"))
|
||||||
|
mapScalar("LongString","kotlin.Long", "ca.gosyer.jui.data.scalars.LongStringScalar")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,6 +20,8 @@ import ca.gosyer.jui.domain.server.service.ServerPreferences
|
|||||||
import ca.gosyer.jui.domain.settings.service.SettingsRepository
|
import ca.gosyer.jui.domain.settings.service.SettingsRepository
|
||||||
import ca.gosyer.jui.domain.source.service.SourceRepository
|
import ca.gosyer.jui.domain.source.service.SourceRepository
|
||||||
import ca.gosyer.jui.domain.updates.service.UpdatesRepository
|
import ca.gosyer.jui.domain.updates.service.UpdatesRepository
|
||||||
|
import com.apollographql.apollo3.ApolloClient
|
||||||
|
import com.apollographql.apollo3.network.ktorClient
|
||||||
import de.jensklingenberg.ktorfit.Ktorfit
|
import de.jensklingenberg.ktorfit.Ktorfit
|
||||||
import me.tatarka.inject.annotations.Provides
|
import me.tatarka.inject.annotations.Provides
|
||||||
|
|
||||||
@@ -35,6 +37,15 @@ interface DataComponent {
|
|||||||
.baseUrl(serverPreferences.serverUrl().get().toString().addSuffix('/'))
|
.baseUrl(serverPreferences.serverUrl().get().toString().addSuffix('/'))
|
||||||
.build()
|
.build()
|
||||||
|
|
||||||
|
@Provides
|
||||||
|
fun apolloClient(
|
||||||
|
http: Http,
|
||||||
|
serverPreferences: ServerPreferences,
|
||||||
|
) = ApolloClient.Builder()
|
||||||
|
.serverUrl(serverPreferences.serverUrl().get().toString())
|
||||||
|
.ktorClient(http)
|
||||||
|
.build()
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
fun backupRepository(ktorfit: Ktorfit) = ktorfit.create<BackupRepository>()
|
fun backupRepository(ktorfit: Ktorfit) = ktorfit.create<BackupRepository>()
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,26 @@
|
|||||||
|
/*
|
||||||
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package ca.gosyer.jui.data.scalars
|
||||||
|
|
||||||
|
import com.apollographql.apollo3.api.Adapter
|
||||||
|
import com.apollographql.apollo3.api.CustomScalarAdapters
|
||||||
|
import com.apollographql.apollo3.api.json.JsonReader
|
||||||
|
import com.apollographql.apollo3.api.json.JsonWriter
|
||||||
|
|
||||||
|
object LongStringScalar : Adapter<Long> {
|
||||||
|
override fun fromJson(reader: JsonReader, customScalarAdapters: CustomScalarAdapters): Long {
|
||||||
|
return reader.nextString()!!.toLong()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun toJson(
|
||||||
|
writer: JsonWriter,
|
||||||
|
customScalarAdapters: CustomScalarAdapters,
|
||||||
|
value: Long,
|
||||||
|
) {
|
||||||
|
writer.value(value.toString())
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -38,7 +38,7 @@ kotlinInject = "0.6.3"
|
|||||||
# Network
|
# Network
|
||||||
ktor = "2.3.9"
|
ktor = "2.3.9"
|
||||||
ktorfit = "1.12.0"
|
ktorfit = "1.12.0"
|
||||||
apollo = "3.8.3"
|
apollo = "4.0.0-beta.5"
|
||||||
|
|
||||||
# Logging
|
# Logging
|
||||||
slf4j = "2.0.12"
|
slf4j = "2.0.12"
|
||||||
@@ -129,7 +129,8 @@ ktor-websockets = { module = "io.ktor:ktor-client-websockets", version.ref = "kt
|
|||||||
ktor-auth = { module = "io.ktor:ktor-client-auth", version.ref = "ktor" }
|
ktor-auth = { module = "io.ktor:ktor-client-auth", version.ref = "ktor" }
|
||||||
ktorfit-lib = { module = "de.jensklingenberg.ktorfit:ktorfit-lib-light", version.ref = "ktorfit" }
|
ktorfit-lib = { module = "de.jensklingenberg.ktorfit:ktorfit-lib-light", version.ref = "ktorfit" }
|
||||||
ktorfit-ksp = { module = "de.jensklingenberg.ktorfit:ktorfit-ksp", version.ref = "ktorfit" }
|
ktorfit-ksp = { module = "de.jensklingenberg.ktorfit:ktorfit-ksp", version.ref = "ktorfit" }
|
||||||
apollo = { module = "com.apollographql.apollo3:apollo-runtime", version.ref = "apollo" }
|
apollo-runtime = { module = "com.apollographql.apollo3:apollo-runtime", version.ref = "apollo" }
|
||||||
|
apollo-engine-ktor = { module = "com.apollographql.apollo3:apollo-engine-ktor", version.ref = "apollo" }
|
||||||
|
|
||||||
# Logging
|
# Logging
|
||||||
logging-slf4j-api = { module = "org.slf4j:slf4j-api", version.ref = "slf4j" }
|
logging-slf4j-api = { module = "org.slf4j:slf4j-api", version.ref = "slf4j" }
|
||||||
|
|||||||
Reference in New Issue
Block a user