Skip to content

Commit 4030cae

Browse files
authored
Allow multiple success responses in ApolloCall.execute() (#6772)
1 parent 8c8c03a commit 4030cae

File tree

1 file changed

+3
-4
lines changed
  • libraries/apollo-runtime/src/commonMain/kotlin/com/apollographql/apollo

1 file changed

+3
-4
lines changed

libraries/apollo-runtime/src/commonMain/kotlin/com/apollographql/apollo/ApolloCall.kt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,8 @@ class ApolloCall<D : Operation.Data> internal constructor(
153153
*
154154
* [execute] calls [toFlow] and filters out cache or network errors to return a single success [ApolloResponse].
155155
*
156-
* [execute] throws if more than one success [ApolloResponse] is returned, for an example, if [operation] is a subscription or a `@defer` query.
157-
* In those cases use [toFlow] instead.
156+
* If more than one success [ApolloResponse] is emitted, for an example, if [operation] is a subscription or a `@defer` query, the first one is returned.
157+
* Prefer [toFlow] for those cases to handle all the responses.
158158
*
159159
* [execute] may fail due to an I/O error, a cache miss or other reasons. In that case, check [ApolloResponse.exception]:
160160
* ```
@@ -204,8 +204,7 @@ class ApolloCall<D : Operation.Data> internal constructor(
204204
}
205205
}
206206

207-
1 -> successResponses.first()
208-
else -> throw DefaultApolloException("The operation returned multiple items, use .toFlow() instead of .execute()")
207+
else -> successResponses.first()
209208
}
210209
}
211210
}

0 commit comments

Comments
 (0)