Return Partial Manga Data with Errors (#2166)

* Return Partial Manga Data with Errors

* Lint

* Optimize imports

* Update server/src/main/kotlin/suwayomi/tachidesk/graphql/mutations/MangaMutation.kt

Co-authored-by: schroda <50052685+schroda@users.noreply.github.com>

* Update server/src/main/kotlin/suwayomi/tachidesk/graphql/mutations/MangaMutation.kt

Co-authored-by: schroda <50052685+schroda@users.noreply.github.com>

---------

Co-authored-by: schroda <50052685+schroda@users.noreply.github.com>
This commit is contained in:
Mitchell Syer
2026-07-05 14:22:28 -04:00
committed by GitHub
parent f473135d04
commit 41d23c0a09
2 changed files with 29 additions and 12 deletions

View File

@@ -10,7 +10,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
- .
### Changed
- .
- (**Manga/API**) Return partial responses for Manga And Chapters query
### Fixed
- .

View File

@@ -3,6 +3,8 @@
package suwayomi.tachidesk.graphql.mutations
import com.expediagroup.graphql.generator.annotations.GraphQLDeprecated
import com.expediagroup.graphql.server.extensions.toGraphQLError
import graphql.execution.DataFetcherResult
import org.jetbrains.exposed.v1.core.LikePattern
import org.jetbrains.exposed.v1.core.Op
import org.jetbrains.exposed.v1.core.and
@@ -181,15 +183,21 @@ class MangaMutation {
)
@RequireAuth
fun fetchMangaAndChapters(input: FetchMangaAndChaptersInput): CompletableFuture<FetchMangaAndChaptersPayload?> {
fun fetchMangaAndChapters(input: FetchMangaAndChaptersInput): CompletableFuture<DataFetcherResult<FetchMangaAndChaptersPayload?>> {
val (clientMutationId, id, fetchManga, fetchChapters) = input
return future {
Manga.updateMangaAndChapters(
mangaId = id,
updateManga = fetchManga,
updateChapters = fetchChapters,
)
val error =
try {
Manga.updateMangaAndChapters(
mangaId = id,
updateManga = fetchManga,
updateChapters = fetchChapters,
)
null
} catch (e: Exception) {
e
}
val (manga, chapters) =
transaction {
@@ -202,11 +210,20 @@ class MangaMutation {
.map { ChapterType(it) },
)
}
FetchMangaAndChaptersPayload(
clientMutationId = clientMutationId,
manga = MangaType(manga),
chapters = chapters,
)
@Suppress("UNCHECKED_CAST")
DataFetcherResult
.newResult<FetchMangaAndChaptersPayload>()
.data(
FetchMangaAndChaptersPayload(
clientMutationId = clientMutationId,
manga = MangaType(manga),
chapters = chapters,
),
).also {
if (error != null) {
it.error(error.toGraphQLError())
}
}.build() as DataFetcherResult<FetchMangaAndChaptersPayload?>
}
}