Joel Denke
08/07/2025, 2:53 PMprivate fun ApplicationCall.context(uid: String?): ExecutionContext {
return AuthenticationContext(uid) + DatastoreContext(datastore) + CacheControlContext()
}
Will I then be able to get first parameter in my class methods that using @GraphQLQuery?
Or do I need some kind of singleton holding all deps?
I am trying to use Ktor server DI library, but I dont mind change to something else. Trying to structure my Apollo code better.mbonnin
08/07/2025, 3:17 PMExecutionContext
is available on each an every field/resolver, it will go down your tree.mbonnin
08/07/2025, 3:18 PMExecutableSchemaBuilder
with a lambda for the root Query
and Mutation
types and pass arguments there. Those will only be available at the rootmbonnin
08/07/2025, 3:18 PMJoel Denke
08/07/2025, 3:18 PMJoel Denke
08/07/2025, 3:20 PM@GraphQLQuery
class Query {
fun skills(executionContext: ExecutionContext): List<Skill> {
return executionContext.firestore().document()
}
}
Where I need to send in FirestoreCOntext and create extension firestore?Joel Denke
08/07/2025, 3:21 PMmbonnin
08/07/2025, 3:25 PM@GraphQLQuery
class RootQuery {
fun rootFields(executionContext: ExeuctionContext) {
// retrieve your context here
}
}
// later
val executableSchema = ServiceExecutableSchemaBuilder().build()
apolloModule(executableSchema, executionContext = {
MyExecutionContext(foobar)
})
2.
@GraphQLQuery
class RootQuery(val context: MyArguments) {
// root field go here
}
// later
val executableSchema = ServiceExecutableSchemaBuilder().build()
.queryRoot {
RootQuery(myArguments)
}
.build()
mbonnin
08/07/2025, 3:26 PMExecutionContext
works like CoroutinesContext
, it's a Map-ish
APIJoel Denke
08/07/2025, 3:28 PMmbonnin
08/07/2025, 3:28 PMJoel Denke
08/07/2025, 3:28 PMmbonnin
08/07/2025, 3:28 PMJoel Denke
08/07/2025, 3:29 PMJoel Denke
08/07/2025, 3:29 PMmbonnin
08/07/2025, 3:29 PMJoel Denke
08/07/2025, 3:29 PMJoel Denke
08/07/2025, 3:30 PM