Yuri Kornienko
04/15/2020, 9:29 AMjeggy
04/15/2020, 1:33 PMval query = """
query fetchHelloLabel($country: String!) {
hello(country: $country) {
label
}
}
"""
val variables = """
{"country": "English"}
"""
val user = User(id = 1, name = "Username")
val ctx = context {
+user
}
schema.execute(query, variables, ctx)
...
// In your schema definition
query("hello") {
resolver { country: String, ctx: Context ->
val user = ctx.get<User>()
Hello(label = "Hello ${user?.name ?: "unknown"}")
}
}
Here's an examplejeggy
04/15/2020, 1:33 PMjeggy
04/15/2020, 8:02 PM