Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Operation.Data.toJsonString() convenience function for the jvm #4124

Merged
merged 4 commits into from
May 19, 2022
Merged

Add Operation.Data.toJsonString() convenience function for the jvm #4124

merged 4 commits into from
May 19, 2022

Conversation

StylianosGakis
Copy link
Contributor

Allows a more convenient way to simply get the Json representation from Operation.Data without having to manually deal with Buffers etc in client code which the current toJson function requires.

This could be imitated on the clients by instead calling the existing toJson function like this:

fun Operation.Data.toJsonString(
    scalarTypeAdapters: CustomScalarAdapters = CustomScalarAdapters.Empty,
    indent: String? = null,
): String {
    val buffer = Buffer()
    val jsonWriter = BufferedSinkJsonWriter(buffer, indent)
    toJson(jsonWriter, scalarTypeAdapters)
    return buffer.readUtf8()
}

Which should be functionally equivalent to what the introduced function does (if we inlined buildJsonString which toJsonString uses internally)

If you believe that the API doesn't need this addition that would be totally understandable, and you can feel free to simply close this PR 馃檶

@netlify
Copy link

netlify bot commented May 19, 2022

馃懛 Deploy request for apollo-android-docs pending review.

Visit the deploys page to approve it

Name Link
馃敤 Latest commit c5671a7

Copy link
Contributor

@martinbonnin martinbonnin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Copy link
Contributor

@BoD BoD left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

馃憤

@martinbonnin martinbonnin merged commit c23bec0 into apollographql:main May 19, 2022
@StylianosGakis StylianosGakis deleted the stylianos-jvm-Data.toJsonString branch May 20, 2022 07:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants