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

Setting ClientDatabasePrefix via builder causes crash if configuration is present #306

Closed mslagle-godaddy closed 4 years ago

mslagle-godaddy commented 4 years ago

Describe the bug Setting a clientDatabasePrefix programmatically causes a crash if there is a configuration

To Reproduce Steps to reproduce the behavior:

AWSAppSyncClient.builder()
                .context(context)
                .awsConfiguration(appSyncConfig)
                .region(fromName(awsRegion))
                .serverUrl(awsEndpoint)
                .credentialsProvider(credentialsProvider)
                .clientDatabasePrefix("SomePrefix")
                .useClientDatabasePrefix(true)
                .build()

Expected behavior It sets the clientDatabasePrefix on the builder, that prefix is used, and the library doesn't throw an error.

Environment(please complete the following information):

Device Information (please complete the following information):

Additional context The issue is here. If you set the clientDatabasePrefix using the Builder.clientDatabasePrefix() method, but have a config, then it overrides your previously set value with null instead of checking if one is already set programmatically.

Caused by: java.lang.RuntimeException: Please check the AppSync configuration in awsconfiguration.json.
        at com.amazonaws.mobileconnectors.appsync.AWSAppSyncClient$Builder.build(AWSAppSyncClient.java:589)
        at com.godaddy.leka.appsync.AppSyncRegistrationCoordinator$registerAppSyncClient$$inlined$registerWithOverride$1$1.invoke(DependencyService.kt:361)
        at com.godaddy.leka.appsync.AppSyncRegistrationCoordinator$registerAppSyncClient$$inlined$registerWithOverride$1$1.invoke(DependencyService.kt:115)
        at org.koin.core.instance.DefinitionInstance.create(DefinitionInstance.kt:54)
            ... 44 more
     Caused by: java.lang.RuntimeException: ClientDatabasePrefix is not present in AppSync configuration in awsconfiguration.json however .useClientDatabasePrefix(true) is passed in.
        at com.amazonaws.mobileconnectors.appsync.AWSAppSyncClient$Builder.build(AWSAppSyncClient.java:564)
jamesonwilliams commented 4 years ago

@rjuliano Does #308 resolve #306? Do we just need to release it?

rjuliano commented 4 years ago

@rjuliano Does #308 resolve #306? Do we just need to release it?

That's correct.

jamesonwilliams commented 4 years ago

Released in 3.1.1.