From 6541c7b5b7a2219b14ac0524f77939e9b1ee36ef Mon Sep 17 00:00:00 2001 From: Syer10 Date: Fri, 31 Mar 2023 20:30:24 -0400 Subject: [PATCH] Serialize Long as String in graphql --- .../tachidesk/graphql/server/TachideskGraphQLSchema.kt | 4 ++-- .../kotlin/suwayomi/tachidesk/graphql/types/MangaType.kt | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/server/src/main/kotlin/suwayomi/tachidesk/graphql/server/TachideskGraphQLSchema.kt b/server/src/main/kotlin/suwayomi/tachidesk/graphql/server/TachideskGraphQLSchema.kt index 113afb4c..8c41df54 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/graphql/server/TachideskGraphQLSchema.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/graphql/server/TachideskGraphQLSchema.kt @@ -11,7 +11,7 @@ import com.expediagroup.graphql.generator.SchemaGeneratorConfig import com.expediagroup.graphql.generator.TopLevelObject import com.expediagroup.graphql.generator.hooks.FlowSubscriptionSchemaGeneratorHooks import com.expediagroup.graphql.generator.toSchema -import graphql.scalars.ExtendedScalars +import graphql.Scalars import graphql.schema.GraphQLType import suwayomi.tachidesk.graphql.mutations.ChapterMutation import suwayomi.tachidesk.graphql.queries.CategoryQuery @@ -24,7 +24,7 @@ import kotlin.reflect.KType class CustomSchemaGeneratorHooks : FlowSubscriptionSchemaGeneratorHooks() { override fun willGenerateGraphQLType(type: KType): GraphQLType? = when (type.classifier as? KClass<*>) { - Long::class -> ExtendedScalars.GraphQLLong + Long::class -> Scalars.GraphQLString // encode to string for JS else -> super.willGenerateGraphQLType(type) } } diff --git a/server/src/main/kotlin/suwayomi/tachidesk/graphql/types/MangaType.kt b/server/src/main/kotlin/suwayomi/tachidesk/graphql/types/MangaType.kt index 8ded86b4..87672c51 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/graphql/types/MangaType.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/graphql/types/MangaType.kt @@ -19,7 +19,7 @@ import java.util.concurrent.CompletableFuture class MangaType( val id: Int, - val sourceId: String, + val sourceId: Long, val url: String, val title: String, val thumbnailUrl: String?, @@ -37,7 +37,7 @@ class MangaType( ) { constructor(row: ResultRow) : this( row[MangaTable.id].value, - row[MangaTable.sourceReference].toString(), + row[MangaTable.sourceReference], row[MangaTable.url], row[MangaTable.title], row[MangaTable.thumbnail_url], @@ -56,7 +56,7 @@ class MangaType( constructor(dataClass: MangaDataClass) : this( dataClass.id, - dataClass.sourceId, + dataClass.sourceId.toLong(), dataClass.url, dataClass.title, dataClass.thumbnailUrl,