diff --git a/spesialist-api/src/main/kotlin/no/nav/helse/spesialist/api/graphql/SchemaGeneratorHooks.kt b/spesialist-api/src/main/kotlin/no/nav/helse/spesialist/api/graphql/SchemaGeneratorHooks.kt index 22a31897e..b56529615 100644 --- a/spesialist-api/src/main/kotlin/no/nav/helse/spesialist/api/graphql/SchemaGeneratorHooks.kt +++ b/spesialist-api/src/main/kotlin/no/nav/helse/spesialist/api/graphql/SchemaGeneratorHooks.kt @@ -99,12 +99,17 @@ private object LocalDateTimeCoercing : Coercing { locale: Locale, ): LocalDateTime = LocalDateTime.parse(serialize(input, graphQLContext, locale)) } + private object LocalDateCoercing : Coercing { override fun serialize( dataFetcherResult: Any, graphQLContext: GraphQLContext, locale: Locale, - ) = dataFetcherResult.toString() + ): String = + when (dataFetcherResult) { + is StringValue -> dataFetcherResult.value + else -> dataFetcherResult.toString() + } override fun parseValue( input: Any, @@ -118,8 +123,6 @@ private object LocalDateCoercing : Coercing { graphQLContext: GraphQLContext, locale: Locale, ): LocalDate { - val s = serialize(input, graphQLContext, locale) - val d = LocalDate.parse(s) - return d + return LocalDate.parse(serialize(input, graphQLContext, locale)) } }