Ryan Zidago
01/13/2022, 4:58 PMsrc/Application.kt
is mentioned but my automatically generated Application.kt
file is under src/main/kotlin/com.ryanzidago/Application.kt
🤔
Here's the content of my Application.kt
package com.ryanzidago
import io.ktor.server.engine.*
import io.ktor.server.netty.*
import com.ryanzidago.plugins.*
import io.ktor.application.Application
import io.ktor.application.install
import com.apurebase.kgraphql.GraphQL
fun main() {
embeddedServer(Netty, port = 8080, host = "0.0.0.0") {
configureRouting()
}.start(wait = true)
}
fun Application.module(testing: Boolean = false) {
install(GraphQL) {
playground = true
schema {
query("hello") {
resolver { -> "World" }
}
}
}
}
Intellij tells me that there is a problem with the install
(Not enough information to infer type variable B) and playground
(Variable expected) but I cannot figure out what is wrong 🤔
When I type gradle --version
in my project root I get the following output:
ariviv
❯ gradle --version
------------------------------------------------------------
Gradle 7.3.3
------------------------------------------------------------
Build time: 2021-12-22 12:37:54 UTC
Revision: 6f556c80f945dc54b50e0be633da6c62dbe8dc71
Kotlin: 1.5.31
Groovy: 3.0.9
Ant: Apache Ant(TM) version 1.10.11 compiled on July 10 2021
JVM: 17.0.1 (Oracle Corporation 17.0.1+12-39)
OS: Linux 5.4.0-94-generic amd64
Any tips?Dariusz Kuc
01/13/2022, 5:19 PM/graphql
would be used to accept queries (through POST or GET). Unsure how kgraphql
does the routing but I've often seen (and we do it in graphql-kotlin
) the specific /playground
routes (or /graphiql
, /voyager
etc) for the tooling.Ryan Zidago
01/13/2022, 5:21 PMVampire
01/13/2022, 5:23 PMDariusz Kuc
01/13/2022, 5:25 PMRyan Zidago
01/13/2022, 5:28 PMDariusz Kuc
01/13/2022, 5:32 PM/graphql
endpoint for surfacing playground
using GET requests (which does not follow best practices defined in https://graphql.org/learn/serving-over-http/)Vampire
01/13/2022, 5:32 PMApplication.module
color-wise looks unused, should that be called somewhere?Dariusz Kuc
01/13/2022, 5:33 PMgraphql-kotlin
) don't have a tutorial for ktor (there is one for Spring) but there is an example app -> https://github.com/ExpediaGroup/graphql-kotlin/tree/master/examples/server/ktor-server
maybe that can be of some helpVampire
01/13/2022, 5:34 PMmodule
, but I guess this just does not fit the generated template anymore, also because the path is differently and that you simply added the whole functionRyan Zidago
01/13/2022, 5:38 PMVampire
01/13/2022, 5:40 PMRyan Zidago
01/13/2022, 5:41 PMVampire
01/13/2022, 5:44 PMRyan Zidago
01/13/2022, 5:45 PMconfigureRouting()
call in my Application.module
function. Now it works!