From 5ed281d9381f8b3f55aae738d4ab9b80c57c035c Mon Sep 17 00:00:00 2001 From: stylianosgakis Date: Thu, 19 May 2022 11:55:05 +0300 Subject: [PATCH] Simply use buildJsonString instead, and mark as experimental --- .../jvmMain/kotlin/com/apollographql/apollo3/api/-Data.kt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/apollo-api/src/jvmMain/kotlin/com/apollographql/apollo3/api/-Data.kt b/apollo-api/src/jvmMain/kotlin/com/apollographql/apollo3/api/-Data.kt index 077ac4b00a0..e579434b29d 100644 --- a/apollo-api/src/jvmMain/kotlin/com/apollographql/apollo3/api/-Data.kt +++ b/apollo-api/src/jvmMain/kotlin/com/apollographql/apollo3/api/-Data.kt @@ -1,6 +1,8 @@ package com.apollographql.apollo3.api +import com.apollographql.apollo3.annotations.ApolloExperimental import com.apollographql.apollo3.api.json.JsonWriter +import com.apollographql.apollo3.api.json.buildJsonString private fun Operation.Data.adapter(): Adapter { val name = this::class.java.name @@ -25,6 +27,9 @@ fun Operation.Data.toJson(jsonWriter: JsonWriter, customScalarAdapters: CustomSc adapter().toJson(jsonWriter, customScalarAdapters, this) } +@ApolloExperimental fun Operation.Data.toJsonString(customScalarAdapters: CustomScalarAdapters = CustomScalarAdapters.Empty, indent: String? = null): String { - return adapter().toJsonString(this, customScalarAdapters, indent) + return buildJsonString(indent) { + toJson(this, customScalarAdapters) + } }