aPureBase / KGraphQL

Pure Kotlin GraphQL implementation
https://kgraphql.io
MIT License
298 stars 58 forks source link

Error on Ktor 2.0.x #200

Closed jklepek closed 1 year ago

jklepek commented 1 year ago

Hey, I've tried to implement KGraphQL with Ktor version 2.0.2, but for the life of me, couldn't get it to work, I would always get JSON parse error unexpected end of file. Inspecting this, in the end I found that the issue is with receiveStream() call in receiveTextWithCorrectEncoding() method. I would get Acquiring blocking primitives on this dispatcher is not allowed. Consider using async channel or doing withContext(Dispatchers.IO) { call.receive<InputStream>().use { ... } } instead. So, when I tried the suggested, it worked. I couldn't make a PR so, here's a suggestion return withContext(Dispatchers.IO) { receiveStream().bufferedReader(charset = suitableCharset).readText() }

ylevanovich commented 1 year ago

We have the same issue.

Alternatively, the code can be changed to following (as how ktor own receiveText() does it):

return receiveChannel().readRemaining().readText(suitableCharset)

funyin commented 1 year ago

Also having this issue. Looking forward to the new release