Skip to content

Commit 3cf86d9

Browse files
samuelAndalonSamuel Vazquez
andauthored
feat(batching): v7 remove execution if a given operation completes with an exception (#2007)
### 📝 Description #2006 Co-authored-by: Samuel Vazquez <[email protected]>
1 parent 4bf3103 commit 3cf86d9

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

executions/graphql-kotlin-dataloader-instrumentation/src/main/kotlin/com/expediagroup/graphql/dataloader/instrumentation/level/state/ExecutionLevelDispatchedState.kt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ class ExecutionLevelDispatchedState(
4848
* for example:
4949
* parsing, validation, execution errors
5050
* persisted query errors
51+
* an exception during execution was thrown
5152
*/
5253
private fun removeExecution(executionId: ExecutionId) {
5354
if (executions.containsKey(executionId)) {
@@ -70,10 +71,8 @@ class ExecutionLevelDispatchedState(
7071
}
7172
return object : SimpleInstrumentationContext<ExecutionResult>() {
7273
override fun onCompleted(result: ExecutionResult?, t: Throwable?) {
73-
result?.let {
74-
if (result.errors.size > 0) {
75-
removeExecution(parameters.executionInput.executionId)
76-
}
74+
if ((result != null && result.errors.size > 0) || t != null) {
75+
removeExecution(parameters.executionInput.executionId)
7776
}
7877
}
7978
}

executions/graphql-kotlin-dataloader-instrumentation/src/main/kotlin/com/expediagroup/graphql/dataloader/instrumentation/syncexhaustion/state/SyncExecutionExhaustedState.kt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ class SyncExecutionExhaustedState(
5151
* for example:
5252
* - parsing, validation errors
5353
* - persisted query errors
54+
* - an exception during execution was thrown
5455
*/
5556
private fun removeExecution(executionId: ExecutionId) {
5657
if (executions.containsKey(executionId)) {
@@ -73,10 +74,8 @@ class SyncExecutionExhaustedState(
7374
}
7475
return object : SimpleInstrumentationContext<ExecutionResult>() {
7576
override fun onCompleted(result: ExecutionResult?, t: Throwable?) {
76-
result?.let {
77-
if (result.errors.size > 0) {
78-
removeExecution(parameters.executionInput.executionId)
79-
}
77+
if ((result != null && result.errors.size > 0) || t != null) {
78+
removeExecution(parameters.executionInput.executionId)
8079
}
8180
}
8281
}

0 commit comments

Comments
 (0)