Skip to content

Commit

Permalink
♻️ Kan ha LocalDate som parameter i mutation
Browse files Browse the repository at this point in the history
  • Loading branch information
chsko committed Jun 4, 2024
1 parent c57a94e commit 0bf2580
Showing 1 changed file with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,17 @@ private object LocalDateTimeCoercing : Coercing<LocalDateTime, String> {
locale: Locale,
): LocalDateTime = LocalDateTime.parse(serialize(input, graphQLContext, locale))
}

private object LocalDateCoercing : Coercing<LocalDate, String> {
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,
Expand All @@ -118,8 +123,6 @@ private object LocalDateCoercing : Coercing<LocalDate, String> {
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))
}
}

0 comments on commit 0bf2580

Please sign in to comment.