another question. How I can access to context in r...
# kgraphql
y
another question. How I can access to context in resolver? For example, I need check token from header
j
Copy code
val 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 example
👍 1
sorry about this. I will try to get this into the documentation later today 🙂
Added this same sample to the documentation 🙂 https://kgraphql.in/docs/reference/resolver/