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

Adding a new enum value to GraphQL schema is not backwards compatible #349

Open admund opened 3 years ago

admund commented 3 years ago

Describe the bug I'm adding a new enum value to my GraphQL schema and I'm starting sending it. My older version apps crash or not work properly, because auto generated pares can handle that. It's done that way:

        final MyEnum something;
        if (somethingStr != null) {
          something = MyEnum.valueOf(somethingStr);
        } else {
          something = null;
        }

And valueOf will throw exception if it will get unknown value.

Expected behavior if we just catch exception and return null, everything will keep working.

        MyEnum something = null;
        if (somethingStr != null) {
          try {
            something = MyEnum.valueOf(something);
          } catch (IllegalArgumentException exception) {
            // some log?
          }
        }

Environment(please complete the following information):

Additional context I'm not sure if this is AppSync problem or GraphQL which is used here. If second option, maybe AppSync should update this lib to newer one. From iOS team I know that this is working correctly with their AppSync SDK.

ksgangadharan commented 1 year ago

Hi, we are facing the same issue in our android app. As @admund suggested, we just need to catch the exception and set the field to null. Especially if we are doing a list query of say 100 records, even if one record has an unrecognised enum value, the entire 100 records do not get processed.