Skip to content

Commit

Permalink
feat(batching): remove execution if a given operation completes with …
Browse files Browse the repository at this point in the history
…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]>
  • Loading branch information
samuelAndalon and Samuel Vazquez authored Jul 11, 2024
1 parent 0aec64b commit cf1c9d6
Showing 1 changed file with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ class SyncExecutionExhaustedState(
* for example:
* - parsing, validation errors
* - persisted query errors
* - an exception during execution was thrown
*/
private fun removeExecution(executionId: ExecutionId) {
if (executions.containsKey(executionId)) {
Expand All @@ -74,10 +75,8 @@ class SyncExecutionExhaustedState(
}
return object : SimpleInstrumentationContext<ExecutionResult>() {
override fun onCompleted(result: ExecutionResult?, t: Throwable?) {
result?.let {
if (result.errors.size > 0) {
removeExecution(parameters.executionInput.executionId)
}
if ((result != null && result.errors.size > 0) || t != null) {
removeExecution(parameters.executionInput.executionId)
}
}
}
Expand Down

0 comments on commit cf1c9d6

Please sign in to comment.