awslabs / aws-mobile-appsync-sdk-android

Android SDK for AWS AppSync.
https://docs.amplify.aws/sdk/api/graphql/q/platform/android/
Apache License 2.0
105 stars 58 forks source link

No callback triggered after executing query #335

Open AlexKashi opened 3 years ago

AlexKashi commented 3 years ago

Describe the bug A clear and concise description of what the bug is.

We run a version check by querying appsync when the onUserStateChanged userstate == SIGNED_IN.

Sometimes this version check fails to complete, no failure, no timeout, no response. This usually only happens once when the app is first started, when closing and reopening the app it works.

This problem typically happens when a user opens the app for the first time

To Reproduce Steps to reproduce the behavior:


override fun onUserStateChanged(details: UserStateDetails) {
    when (details.userState) {
        UserState.SIGNED_IN -> {
             versionCheck() // queries appsyync for version info
        }

           // more cases

    }
}

fun versionCheck() {
    let versionCode = 1
    let versionName = 1.0.0

    val query = GetVersionInfoQuery.builder().versionCode(versionCode).versionName(versionName).build()
    client.query(query)
        .responseFetcher(NETWORK_ONLY)
        .enqueue(object : GraphQLCall.Callback<GetVersionInfoQuery.Data?>() {
            override fun onResponse(@Nonnull response: Response<GetVersionInfoQuery.Data?>) {

                // Handle Success (never called)

            }

            override fun onFailure(@Nonnull e: ApolloException) {

                // Handle Fail (never called)

            }
        })
}

Expected behavior A clear and concise description of what you expected to happen.

Execute the query, and get a response either success or failure.

Environment(please complete the following information):

Device Information (please complete the following information):