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 } }