Skip to content

Commit

Permalink
Simply use buildJsonString instead, and mark as experimental
Browse files Browse the repository at this point in the history
  • Loading branch information
StylianosGakis committed May 19, 2022
1 parent fc88557 commit 5ed281d
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -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<Operation.Data> {
val name = this::class.java.name
Expand All @@ -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)
}
}

0 comments on commit 5ed281d

Please sign in to comment.