I have joined the channel to have a chat about gra...
# ktor
a
I have joined the channel to have a chat about graphql support for ktor, would this be the right place to open a thread about it?
r
I think it is a good place to start. I have tried GraphQl multiplatform and I was able to run the plugin for generation of models and queries, but I was unable to run them on iOS. So I’ve tried to run them manually with Ktor and it worked. here is a snippet
Copy code
suspend fun getLaunches(): List<GetLaunchesQuery.Launch> {
        val query = GetLaunchesQuery()
        val request = query.composeRequestBody()
            .toByteArray()
        val response = httpClient.request<HttpResponse> {
            body = request
            method = <http://HttpMethod.Post|HttpMethod.Post>
            url(graphQlurl)
            header("Accept", "application/json")
            header("Content-Type", "application/json")
        }
        val responseData = query.parse(response.readBytes().toByteString())
return responseData
            .data?.launches?.launches
            ?.mapNotNull { it }
            .orEmpty()
}
a
what library did you use?
r
just
com.apollographql.apollo:apollo-api:2.4.5
you also need to use gradle plugin
Copy code
id("com.apollographql.apollo")
from
Copy code
classpath("com.apollographql.apollo:apollo-gradle-plugin:2.4.5")
a
that’s also interesting, still another approach to the issue 🙂
m
@Adam Firen So when you say Graphql support for Ktor, you mean on the client side?
a
Server side
m
Hmmm there's no official support for Graphql, but there are libraries like #kgraphql #graphql-kotlin which can you help you with creating a Graphql endpoint with Ktor
a
Yeah I am aware of them. I was more interested if there is any ktor creators iniciative or they want to leave it to the community and the projects you have mentioned
👍🏼 1