bram93
11/17/2020, 7:39 PMkottlinx.serialization
be utilized to parse a GraphQLType
(from graphql-java) and map it to a POJO without reflection costs? Using a custom format of some sort?Big Chungus
11/17/2020, 7:55 PMBig Chungus
11/17/2020, 7:56 PMBig Chungus
11/17/2020, 7:57 PMVampire
11/17/2020, 9:36 PMkotlinx.serialization
is always without reflection, that's one of its core concepts. Only exception might be some specific methods that search for the serializer by reflection. But afair you get warned if you use those.mbonnin
11/17/2020, 10:21 PMmbonnin
11/17/2020, 10:23 PMMarc Knaup
11/18/2020, 3:50 AMkotlinx.serialization
for GraphQL parsing.
1) The structure of GraphQL responses is not static but depends on the query. If your queries are static and all result in a very predictable structure then this shouldn’t be an issue though.
2) Kotlin has no notion of union types so those will need special handling.
3) You need a serializer. If you’re in full control over the types then you can use annotations and model around the limitations of kotlinx.serialization
. If not they you’d have to write your own serializers which is quite painful.
Apart from that… A GraphQL response is simply JSON. Everything that’s JSON you can parse with kotlinx.serialization
somehow. There are just some limitations you may have to work around.