I have the following CustomTypeScalar in my schema
public class JSON {
public companion object {
public val type: CustomScalarType = CustomScalarType("JSON", "kotlin.Any")
}
}
Any here is a Map<String, Any>.
When i create my Mutation and pass in a JsonObject, i get an error – cannot convert to Json
And when I pass in a json formatted string it again throws an error since it is not able to understand that string.
I need a Custom Adapter here but not sure how to convert Map<String, Any> to JSON via the Adapter.
Could someone please help. Thanks
I think what is needed is an Adapter of this kind:
class CustomJSONAdapter: Adapter<JSON> {
override fun fromJson(reader: JsonReader, customScalarAdapters: CustomScalarAdapters): JSON {
TODO("Not yet implemented")
}
override fun toJson(
writer: JsonWriter,
customScalarAdapters: CustomScalarAdapters,
value: JSON
) {
TODO("Not yet implemented")
}
}
But i am not sure how to use the above adapter with a Map<String, Any>.