Skip to content

Commit cf1c9d6

Browse files
samuelAndalonSamuel Vazquez
andauthored
feat(batching): remove execution if a given operation completes with an exception (#2006)
### 📝 Description Example: a persisted query is found, but operationName in the http request is not in the persisted document, causing an unknown operation exception (UnknownOperationException). Exceptions are converted into graphQL errors at later point, initially thought those errors from exceptions would be in the execution result. Co-authored-by: Samuel Vazquez <[email protected]>
1 parent 0aec64b commit cf1c9d6

File tree

1 file changed

+3
-4
lines changed
  • executions/graphql-kotlin-dataloader-instrumentation/src/main/kotlin/com/expediagroup/graphql/dataloader/instrumentation/syncexhaustion/state

1 file changed

+3
-4
lines changed

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
@@ -52,6 +52,7 @@ class SyncExecutionExhaustedState(
5252
* for example:
5353
* - parsing, validation errors
5454
* - persisted query errors
55+
* - an exception during execution was thrown
5556
*/
5657
private fun removeExecution(executionId: ExecutionId) {
5758
if (executions.containsKey(executionId)) {
@@ -74,10 +75,8 @@ class SyncExecutionExhaustedState(
7475
}
7576
return object : SimpleInstrumentationContext<ExecutionResult>() {
7677
override fun onCompleted(result: ExecutionResult?, t: Throwable?) {
77-
result?.let {
78-
if (result.errors.size > 0) {
79-
removeExecution(parameters.executionInput.executionId)
80-
}
78+
if ((result != null && result.errors.size > 0) || t != null) {
79+
removeExecution(parameters.executionInput.executionId)
8180
}
8281
}
8382
}

0 commit comments

Comments
 (0)