Hello! How do you make type safe requests with Kto...
# server
i
Hello! How do you make type safe requests with Ktor on both the secret and the client? Do you simply put the content negotiation and resources classes in a shared module and call it good enough?
c
secret = server? I did this type of thing with OpenAPIv3 and GraphQL: two ways to achieve fully type API barriers. Bonus these two provide ways to generate client libs in a plethora of languages.
i
Yes sorry typo. Did you implement both a Ktor server and GraphQL server then?
My use case is for the server to be the backend of multiple Kotlin Multiplatform apps. Don't see the value of GraphQL when everything is already in Kotlin.
c
I was more commenting on typed APIs in general. GraphQL i used with Hasura on the server side.
But in an all Kotlin situation I'd make a shared folder with DTOs used by both client and server.
i
Got it thanks!
t
I haven’t used this yet, but there is also type-safe routing which you might also benefit from: • Server: https://ktor.io/docs/type-safe-routing.html • Client: https://ktor.io/docs/type-safe-request.html
128 Views