Fix manga/source and manga/chapters for graphql (#548)
This commit is contained in:
@@ -18,7 +18,6 @@ import suwayomi.tachidesk.graphql.types.SourceNodeList
|
||||
import suwayomi.tachidesk.graphql.types.SourceNodeList.Companion.toNodeList
|
||||
import suwayomi.tachidesk.graphql.types.SourceType
|
||||
import suwayomi.tachidesk.manga.model.table.ExtensionTable
|
||||
import suwayomi.tachidesk.manga.model.table.MangaTable
|
||||
import suwayomi.tachidesk.manga.model.table.SourceTable
|
||||
import suwayomi.tachidesk.server.JavalinSetup.future
|
||||
|
||||
@@ -37,35 +36,6 @@ class SourceDataLoader : KotlinDataLoader<Long, SourceType?> {
|
||||
}
|
||||
}
|
||||
|
||||
class SourceForMangaDataLoader : KotlinDataLoader<Int, SourceType?> {
|
||||
override val dataLoaderName = "SourceForMangaDataLoader"
|
||||
override fun getDataLoader(): DataLoader<Int, SourceType?> = DataLoaderFactory.newDataLoader { ids ->
|
||||
future {
|
||||
transaction {
|
||||
addLogger(Slf4jSqlDebugLogger)
|
||||
|
||||
val itemsByRef = MangaTable.innerJoin(SourceTable)
|
||||
.select { MangaTable.id inList ids }
|
||||
.map { Triple(it[MangaTable.id].value, it[MangaTable.sourceReference], it) }
|
||||
.let { triples ->
|
||||
val sources = buildMap {
|
||||
triples.forEach {
|
||||
if (!containsKey(it.second)) {
|
||||
put(it.second, SourceType(it.third))
|
||||
}
|
||||
}
|
||||
}
|
||||
triples.associate {
|
||||
it.first to sources[it.second]
|
||||
}
|
||||
}
|
||||
|
||||
ids.map { itemsByRef[it] }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class SourcesForExtensionDataLoader : KotlinDataLoader<String, SourceNodeList> {
|
||||
override val dataLoaderName = "SourcesForExtensionDataLoader"
|
||||
override fun getDataLoader(): DataLoader<String, SourceNodeList> = DataLoaderFactory.newDataLoader { ids ->
|
||||
|
||||
@@ -39,7 +39,7 @@ class MangaMutation {
|
||||
val mangas: List<MangaType>
|
||||
)
|
||||
data class UpdateMangasInput(
|
||||
val clientMutationId: String?? = null,
|
||||
val clientMutationId: String? = null,
|
||||
val ids: List<Int>,
|
||||
val patch: UpdateMangaPatch
|
||||
)
|
||||
|
||||
-2
@@ -20,7 +20,6 @@ import suwayomi.tachidesk.graphql.dataLoaders.MangaDataLoader
|
||||
import suwayomi.tachidesk.graphql.dataLoaders.MangaForCategoryDataLoader
|
||||
import suwayomi.tachidesk.graphql.dataLoaders.MangaMetaDataLoader
|
||||
import suwayomi.tachidesk.graphql.dataLoaders.SourceDataLoader
|
||||
import suwayomi.tachidesk.graphql.dataLoaders.SourceForMangaDataLoader
|
||||
import suwayomi.tachidesk.graphql.dataLoaders.SourcesForExtensionDataLoader
|
||||
|
||||
class TachideskDataLoaderRegistryFactory {
|
||||
@@ -37,7 +36,6 @@ class TachideskDataLoaderRegistryFactory {
|
||||
CategoryMetaDataLoader(),
|
||||
CategoriesForMangaDataLoader(),
|
||||
SourceDataLoader(),
|
||||
SourceForMangaDataLoader(),
|
||||
SourcesForExtensionDataLoader(),
|
||||
ExtensionDataLoader(),
|
||||
ExtensionForSourceDataLoader()
|
||||
|
||||
@@ -78,8 +78,8 @@ class MangaType(
|
||||
dataClass.chaptersLastFetchedAt
|
||||
)
|
||||
|
||||
fun chapters(dataFetchingEnvironment: DataFetchingEnvironment): CompletableFuture<List<ChapterType>> {
|
||||
return dataFetchingEnvironment.getValueFromDataLoader<Int, List<ChapterType>>("ChaptersForMangaDataLoader", id)
|
||||
fun chapters(dataFetchingEnvironment: DataFetchingEnvironment): CompletableFuture<ChapterNodeList> {
|
||||
return dataFetchingEnvironment.getValueFromDataLoader<Int, ChapterNodeList>("ChaptersForMangaDataLoader", id)
|
||||
}
|
||||
|
||||
fun age(): Long? {
|
||||
@@ -102,7 +102,7 @@ class MangaType(
|
||||
}
|
||||
|
||||
fun source(dataFetchingEnvironment: DataFetchingEnvironment): CompletableFuture<SourceType?> {
|
||||
return dataFetchingEnvironment.getValueFromDataLoader<Int, SourceType?>("SourceForMangaDataLoader", id)
|
||||
return dataFetchingEnvironment.getValueFromDataLoader<Long, SourceType?>("SourceDataLoader", sourceId)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user