Serialize Long as String in graphql

This commit is contained in:
Syer10
2023-03-31 20:30:24 -04:00
parent 37f41ade43
commit 6541c7b5b7
2 changed files with 5 additions and 5 deletions

View File

@@ -11,7 +11,7 @@ import com.expediagroup.graphql.generator.SchemaGeneratorConfig
import com.expediagroup.graphql.generator.TopLevelObject import com.expediagroup.graphql.generator.TopLevelObject
import com.expediagroup.graphql.generator.hooks.FlowSubscriptionSchemaGeneratorHooks import com.expediagroup.graphql.generator.hooks.FlowSubscriptionSchemaGeneratorHooks
import com.expediagroup.graphql.generator.toSchema import com.expediagroup.graphql.generator.toSchema
import graphql.scalars.ExtendedScalars import graphql.Scalars
import graphql.schema.GraphQLType import graphql.schema.GraphQLType
import suwayomi.tachidesk.graphql.mutations.ChapterMutation import suwayomi.tachidesk.graphql.mutations.ChapterMutation
import suwayomi.tachidesk.graphql.queries.CategoryQuery import suwayomi.tachidesk.graphql.queries.CategoryQuery
@@ -24,7 +24,7 @@ import kotlin.reflect.KType
class CustomSchemaGeneratorHooks : FlowSubscriptionSchemaGeneratorHooks() { class CustomSchemaGeneratorHooks : FlowSubscriptionSchemaGeneratorHooks() {
override fun willGenerateGraphQLType(type: KType): GraphQLType? = when (type.classifier as? KClass<*>) { 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) else -> super.willGenerateGraphQLType(type)
} }
} }

View File

@@ -19,7 +19,7 @@ import java.util.concurrent.CompletableFuture
class MangaType( class MangaType(
val id: Int, val id: Int,
val sourceId: String, val sourceId: Long,
val url: String, val url: String,
val title: String, val title: String,
val thumbnailUrl: String?, val thumbnailUrl: String?,
@@ -37,7 +37,7 @@ class MangaType(
) { ) {
constructor(row: ResultRow) : this( constructor(row: ResultRow) : this(
row[MangaTable.id].value, row[MangaTable.id].value,
row[MangaTable.sourceReference].toString(), row[MangaTable.sourceReference],
row[MangaTable.url], row[MangaTable.url],
row[MangaTable.title], row[MangaTable.title],
row[MangaTable.thumbnail_url], row[MangaTable.thumbnail_url],
@@ -56,7 +56,7 @@ class MangaType(
constructor(dataClass: MangaDataClass) : this( constructor(dataClass: MangaDataClass) : this(
dataClass.id, dataClass.id,
dataClass.sourceId, dataClass.sourceId.toLong(),
dataClass.url, dataClass.url,
dataClass.title, dataClass.title,
dataClass.thumbnailUrl, dataClass.thumbnailUrl,