From 41d23c0a0922eae2165cbf3699f5f08d7c60c9a7 Mon Sep 17 00:00:00 2001 From: Mitchell Syer Date: Sun, 5 Jul 2026 14:22:28 -0400 Subject: [PATCH] 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> --- CHANGELOG.md | 2 +- .../graphql/mutations/MangaMutation.kt | 39 +++++++++++++------ 2 files changed, 29 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0f1667f29..11073f0a9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 - . diff --git a/server/src/main/kotlin/suwayomi/tachidesk/graphql/mutations/MangaMutation.kt b/server/src/main/kotlin/suwayomi/tachidesk/graphql/mutations/MangaMutation.kt index 00c2a6224..851e765d6 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/graphql/mutations/MangaMutation.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/graphql/mutations/MangaMutation.kt @@ -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 { + fun fetchMangaAndChapters(input: FetchMangaAndChaptersInput): CompletableFuture> { 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() + .data( + FetchMangaAndChaptersPayload( + clientMutationId = clientMutationId, + manga = MangaType(manga), + chapters = chapters, + ), + ).also { + if (error != null) { + it.error(error.toGraphQLError()) + } + }.build() as DataFetcherResult } }