ktor-server: What coroutine context should be used?
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 25/100
- Issue type
- Documentation
- Clarity
- Needs clarification
- Activity status
- Stale
- Tech stack
- graphql, kotlin
- Domain
- api, backend, documentation
Research direction
Review the structured-concurrency documentation linked in the issue alongside the resolver's DataFetchingEnvironment and CoroutineScope usage. Check how the current CoroutineContext differs from the scope stored in GraphQLContext, and clarify which scope applies to parallel work and whether the Ktor Application scope is appropriate. Done means the documentation answers these scope and lifecycle questions.
Written by the indexing model from the issue text.
Description
I have the resolver shown below. It can access its current CoroutineContext object but also another CoroutineContext object via the DataFetchingEnvironment.
class MyResolver : Query {
suspend fun myQuery(dfe: DataFetchingEnvironment): String {
val currentCoroutineContext = kotlin.coroutines.coroutineContext
val otherCoroutineContext = (dfe.graphQlContext.get(CoroutineScope::class) as CoroutineScope).coroutineContext
}
}
These two CoroutineContext objects are not the same.
The documentation states:
In order to preserve coroutine context, we need to populate GraphQLContext map with a CoroutineScope that should be used to execute any suspendable functions
Do I understand it correct that I should use the CoroutineContext from the DataFetchingEnvironment to start a new coroutine and NOT the given current CoroutineContext object?
Which coroutine context or better coroutine scope should I use, if I would like to start a coroutine in parallel so that the response goes back immediately without waiting for the result? Does it still make sense to use this scope: https://api.ktor.io/ktor-server/ktor-server-core/io.ktor.server.application/-application/index.html?
- Dominant language
- Kotlin
- Stars
- 1.8k
- Forks
- 380
- Avg merge
- 5h 6m
- Merged PRs (30d)
- 4
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from ExpediaGroup/graphql-kotlin
-
FlowSubscriptionExecutionStrategy never calls subscriptionEventExecutionDone, leaking a CallStack per subscription eventPossibly taken @JBassett claimed this 45 days ago. Opentype: bug
Difficulty 2/5 1-3 hours Newbie friendliness 35/100
ExpediaGroup/graphql-kotlin#2224 ·
-
Difficulty 5/5 Over a week Newbie friendliness 25/100
ExpediaGroup/graphql-kotlin#2219 ·
-
GraphQL-java 25 v 26 DataFetchingEnvironment.getDataLoader - wrong nullability of VMay be free again @samuelAndalon claimed this 163 days ago, and no pull request is open. Open
ExpediaGroup/graphql-kotlin#2180 · 3 comments · 1 assignee ·
-
type: bug
Difficulty 4/5 3-5 days Newbie friendliness 38/100
ExpediaGroup/graphql-kotlin#2159 · 4 comments ·
-
generateSDL to handle multiple SchemaGeneratorHooksProviders found on the classpathPossibly taken @gaurav0107 claimed this 206 days ago. Opentype: enhancement
Difficulty 5/5 Over a week Newbie friendliness 35/100
ExpediaGroup/graphql-kotlin#2150 ·
All issues in ExpediaGroup/graphql-kotlin
Similar issues
-
ci
Difficulty 2/5 Half a day Newbie friendliness 76/100
ft-dev-org/cloudbridge-oss#103 ·
Maintainers usually reply within 1 day
-
enhancement priority: medium
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
morinoparty/MineAuth#546 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
livesport/homer#597 · 1 comment ·
Maintainers usually reply within 1 day
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
PixelPlayerHQ/PixelPlayerOSS#325 ·
Maintainers usually reply within 1 day