Skip to content

add finalize to NadelTransform - #693

Merged
temaEmelyan merged 8 commits into
masterfrom
add-finalise-to-nadel-transform
Jul 25, 2025
Merged

add finalize to NadelTransform#693
temaEmelyan merged 8 commits into
masterfrom
add-finalise-to-nadel-transform

Conversation

@temaEmelyan

Copy link
Copy Markdown
Member

Please make sure you consider the following:

  • Add tests that use __typename in queries
  • Does this change work with all nadel transformations (rename, type rename, hydration, etc)? Add tests for this.
  • Is it worth using hints for this change in order to be able to enable a percentage rollout?
  • Do we need to add integration tests for this change in the graphql gateway?
  • Do we need a pollinator check for this?

@github-actions

github-actions Bot commented Jul 24, 2025

Copy link
Copy Markdown

Test Results

  601 files  +  601    601 suites  +601   59s ⏱️ +59s
1 998 tests +1 998  1 487 ✅ +1 487  511 💤 +511  0 ❌ ±0 
2 006 runs  +2 006  1 495 ✅ +1 495  511 💤 +511  0 ❌ ±0 

Results for commit c9cc58f. ± Comparison against base commit 08807ea.

♻️ This comment has been updated with latest results.

@temaEmelyan temaEmelyan self-assigned this Jul 25, 2025
if (isSkipIncludeSpecialField(field) && ((transform as NadelTransform<*>) !is NadelSkipIncludeTransform)) {
null
} else {
val executionTransformContext = if (transformContexts.containsKey(transform)) {

@temaEmelyan temaEmelyan Jul 25, 2025

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just

transformContexts.getOrPut(transform) {...

without if (transformContexts.containsKey(transform)) { is not enough, we need to check if a key was already added with the null value.

map.getOrPut(k) { fn() } runs fn() every time when k: null was added to the map. so we check if there is an explicit (transform: null) mapping in the map already

)
}
}
finalizeJobs.awaitAll()

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If there's no result then launch { is better of async { and .joinAll() instead of .awaitAll()

But also I think if you use this coroutineContext it will only exit the lambda once all the child coroutines are done, so you don't actually need .joinAll()

e.g. this

suspend fun main() {
    coroutineScope {
        List(3) {
            launch {
                println("Start")
                delay(1.seconds)
                println("Ok")
            }
        }
    }
    println("Hello")
}

Prints

Start
Start
Start
Ok
Ok
Ok
Hello

So just coroutineScope { contextByTransform.forEach { launch { <work> } } } should be sufficient.

val queryTransformTimingStep: NadelInstrumentationTimingParameters.Step,
val resultTransformTimingStep: NadelInstrumentationTimingParameters.Step,
val state: T,
val transformServiceExecutionContext: NadelTransformServiceExecutionContext?,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like we should just have a Map<NadelTransform, NadelTransformServiceExecutionContext> instead of storing this in every Step

val executionSteps: MutableMap<ExecutableNormalizedField, List<NadelExecutionPlan.Step<Any>>> =
mutableMapOf()

val transformContexts: MutableMap<NadelTransform<Any>, NadelTransformServiceExecutionContext?> =

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I feel like we should pass this into NadelExecutionPlan instead of storing it in every Step

But either way nbd let's fix that later

@temaEmelyan

Copy link
Copy Markdown
Member Author

@gnawf thanks, I will address in a follow up PR

@temaEmelyan
temaEmelyan merged commit c54c0f9 into master Jul 25, 2025
3 checks passed
@temaEmelyan
temaEmelyan deleted the add-finalise-to-nadel-transform branch July 25, 2025 05:12
@gnawf gnawf mentioned this pull request Aug 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants