ExpediaGroup / graphql-kotlin

Libraries for running GraphQL in Kotlin
https://opensource.expediagroup.com/graphql-kotlin/
Apache License 2.0
1.74k stars 351 forks source link

feat: fastjson2 for serialization of GraphQLResponse and deserialization of GraphQLRequest #2040

Closed samuelAndalon closed 1 month ago

samuelAndalon commented 1 month ago

:pencil: Description

the previous integration of kotlinx-serialization represented a performance improvement when deserializing requests, however, responses are still being deserialized with jackson, recently we found that fastjson2 is the fastest serialization library for the jvm.

this PR adds an opt-in support for fastjson2 which provides an easy integration with springboot codecs, the serializer relies on the same jackson annotation, and just had to write a deserializer because of the polymorphic nature of GraphQLRequest and GraphQLReponse

benchmark results

GraphQLRequest deserialization

image

GraphQLResponse serialization

image