mirror of
https://github.com/Suwayomi/Suwayomi-Server.git
synced 2026-07-09 13:54:36 -05:00
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:
@@ -10,7 +10,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
|
|||||||
- .
|
- .
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
- .
|
- (**Manga/API**) Return partial responses for Manga And Chapters query
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
- .
|
- .
|
||||||
|
|||||||
@@ -3,6 +3,8 @@
|
|||||||
package suwayomi.tachidesk.graphql.mutations
|
package suwayomi.tachidesk.graphql.mutations
|
||||||
|
|
||||||
import com.expediagroup.graphql.generator.annotations.GraphQLDeprecated
|
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.LikePattern
|
||||||
import org.jetbrains.exposed.v1.core.Op
|
import org.jetbrains.exposed.v1.core.Op
|
||||||
import org.jetbrains.exposed.v1.core.and
|
import org.jetbrains.exposed.v1.core.and
|
||||||
@@ -181,15 +183,21 @@ class MangaMutation {
|
|||||||
)
|
)
|
||||||
|
|
||||||
@RequireAuth
|
@RequireAuth
|
||||||
fun fetchMangaAndChapters(input: FetchMangaAndChaptersInput): CompletableFuture<FetchMangaAndChaptersPayload?> {
|
fun fetchMangaAndChapters(input: FetchMangaAndChaptersInput): CompletableFuture<DataFetcherResult<FetchMangaAndChaptersPayload?>> {
|
||||||
val (clientMutationId, id, fetchManga, fetchChapters) = input
|
val (clientMutationId, id, fetchManga, fetchChapters) = input
|
||||||
|
|
||||||
return future {
|
return future {
|
||||||
|
val error =
|
||||||
|
try {
|
||||||
Manga.updateMangaAndChapters(
|
Manga.updateMangaAndChapters(
|
||||||
mangaId = id,
|
mangaId = id,
|
||||||
updateManga = fetchManga,
|
updateManga = fetchManga,
|
||||||
updateChapters = fetchChapters,
|
updateChapters = fetchChapters,
|
||||||
)
|
)
|
||||||
|
null
|
||||||
|
} catch (e: Exception) {
|
||||||
|
e
|
||||||
|
}
|
||||||
|
|
||||||
val (manga, chapters) =
|
val (manga, chapters) =
|
||||||
transaction {
|
transaction {
|
||||||
@@ -202,11 +210,20 @@ class MangaMutation {
|
|||||||
.map { ChapterType(it) },
|
.map { ChapterType(it) },
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@Suppress("UNCHECKED_CAST")
|
||||||
|
DataFetcherResult
|
||||||
|
.newResult<FetchMangaAndChaptersPayload>()
|
||||||
|
.data(
|
||||||
FetchMangaAndChaptersPayload(
|
FetchMangaAndChaptersPayload(
|
||||||
clientMutationId = clientMutationId,
|
clientMutationId = clientMutationId,
|
||||||
manga = MangaType(manga),
|
manga = MangaType(manga),
|
||||||
chapters = chapters,
|
chapters = chapters,
|
||||||
)
|
),
|
||||||
|
).also {
|
||||||
|
if (error != null) {
|
||||||
|
it.error(error.toGraphQLError())
|
||||||
|
}
|
||||||
|
}.build() as DataFetcherResult<FetchMangaAndChaptersPayload?>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user