ermadmi78 / kobby

Kobby is a codegen plugin of Kotlin DSL Client by GraphQL schema. The generated DSL supports execution of complex GraphQL queries, mutation and subscriptions in Kotlin with syntax similar to native GraphQL syntax.
Apache License 2.0
83 stars 4 forks source link

[WIP] Add Support for Kotlinx.Serialization #32

Closed EpicSquid closed 1 year ago

EpicSquid commented 1 year ago

This is a WIP implementation of Kotlinx Serialization support for Kobby. It still needs documentation updates and tests added. Addresses #7

The @Contextual annotation is added to handle deserializing of Any? type fields. This still needs unit tests before I am completely happy with its addition.

ermadmi78 commented 1 year ago

Hi, @EpicSquid. Thank you for pull request. I will definitely take into account your experience when developing a production version of Kotlinx.Serialization support.

EpicSquid commented 1 year ago

It's all good. I'm happy to keep updating, adding tests and making changes etc. if you do want to build of this. Definitely not production ready yet but it is a start.

ermadmi78 commented 1 year ago

@EpicSquid, can you please expand more details about UnauthorizedException commit? Where did you see the UnauthorizedException error type? I found one such case here. Unfortunately, I was unable to find any standards for possible error types in GraphQL responses. Perhaps we should stop using enums for error types and return the error type as a string.

EpicSquid commented 1 year ago

I think that's quite reasonable. It was thrown by aws appsync in my testing and I forgot to remove it since it isn't relevant in this pull request in specific.

ermadmi78 commented 1 year ago

Unfortunately, cannot implement :( Kotlinx Serialization does not support serialization and deserialization of Map<String, Any?>. Instead, it is suggested to replace Map<String, Any?> with JsonObject. But such a replacement would break the public API compatibility of the generated code. https://github.com/Kotlin/kotlinx.serialization/issues/296

joffrey-bion commented 1 year ago

Any chance this can be reopened in the light of the latest comment here? https://github.com/ermadmi78/kobby/issues/7#issuecomment-1445383817

I'm looking forward to seeing Kotlinx Serialization support :)

ermadmi78 commented 1 year ago

Yes, I will try to support Kotlinx Serialization - it has huge potential. Just need to find the time. I recently changed jobs, so I'm very busy right now.

joffrey-bion commented 1 year ago

Cool! And no rush, this is open source :) I'm just glad it's on your radar