Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not throw in Flows #4685

Merged
merged 45 commits into from
Feb 22, 2023
Merged

Do not throw in Flows #4685

merged 45 commits into from
Feb 22, 2023

Conversation

BoD
Copy link
Contributor

@BoD BoD commented Feb 14, 2023

See #4003.

  • Do not throw in HttpNetworkTransport and WebSocketNetworkTransport
  • Adjust ApolloCacheInterceptor, FetchPolicyInterceptor, and ApolloCall,execute() accordingly
  • ThrowingXyzInterceptors, and a throwApolloException parameter on toFlow are added to get the old behavior back

Missing:

  • Apply same changes inside normalized cache incubating package
  • Documentation update
  • Java runtime: I think it'd make sense to remove ApolloCallback.onFailure and only keep onResponse since reponse can have an exception
  • Some bits were removed so we should deprecate them first (in Add deprecation warnings #4610)

@netlify
Copy link

netlify bot commented Feb 14, 2023

Deploy Preview for apollo-android-docs canceled.

Name Link
🔨 Latest commit 9c9da5c
🔍 Latest deploy log https://app.netlify.com/sites/apollo-android-docs/deploys/63f4a9ed70a39a0008a88a53

@BoD BoD changed the title Add ApolloResponse.exception Do not throw in Flows Feb 14, 2023
@BoD BoD marked this pull request as ready for review February 16, 2023 14:52
.exception(AutoPersistedQueriesNotSupported())
.build()
)
return@flow
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

*/
fun <T> MutableExecutionOptions<T>.emitCacheMisses(emitCacheMisses: Boolean) = addExecutionContext(
EmitCacheMissesContext(emitCacheMisses)
)
Copy link
Contributor

@martinbonnin martinbonnin Feb 20, 2023

Choose a reason for hiding this comment

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

Keep it with DeprecationLevel.ERROR and a nice error message?

fun <D : Query.Data> ApolloCall<D>.watch(
fetchThrows: Boolean = false,
refetchThrows: Boolean = false,
): Flow<ApolloResponse<D>> {
Copy link
Contributor

Choose a reason for hiding this comment

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

Keep the overload with DeprecationLevel.ERROR?

@@ -28,7 +27,6 @@ import com.apollographql.apollo3.interceptor.ApolloInterceptor
import com.apollographql.apollo3.interceptor.ApolloInterceptorChain
import com.apollographql.apollo3.mpp.currentTimeMillis
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.catch
Copy link
Contributor

Choose a reason for hiding this comment

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

There's a maybeWriteToCache in this file that certainly needs to check for response.exception before writing to the cache?

Copy link
Contributor

@martinbonnin martinbonnin left a comment

Choose a reason for hiding this comment

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

🚀

@BoD BoD merged commit e6c02d6 into main Feb 22, 2023
@BoD BoD deleted the do-not-throw-in-flows branch February 22, 2023 08:33
@BoD BoD mentioned this pull request Feb 27, 2023
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