anthony castillo
01/02/2020, 4:53 AManthony castillo
01/02/2020, 4:56 AMjeggy
01/02/2020, 1:05 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"}")
}
}
jeggy
01/02/2020, 1:49 PMContext
is a special class and it won't get exposed to your GraphQL api.