dgs-codegen icon indicating copy to clipboard operation
dgs-codegen copied to clipboard

Add serializeCompact to GraphQLQueryRequest

Open carlphilipp opened this issue 1 year ago • 1 comments

Goal

While upgrading from graphql-dgs-codegen-client-core to graphql-dgs-codegen-shared-core, we encountered some issue because the way GraphQLQueryRequest is serialized is slightly different. This PR allows GraphQLQueryRequest to be serialized as compact which is a little bit closer to what we had before. It's IMO a little better when we want to log the query, it stays on one line.

Implementation

To keep backward compatibility with Java, I created a new method. If backward compatibility with java is not an issue, I could just do one method with a default param, something like:

fun serialize(compact: Boolean = true): String {
    ...
}

Testing

I feel like the unit test I added is enough, but let me know if you disagree with that, I can add more tests.

carlphilipp avatar Mar 26 '23 19:03 carlphilipp

Changes are looking good to me.

srinivasankavitha avatar Apr 27 '23 20:04 srinivasankavitha