aws-mobile-appsync-sdk-android icon indicating copy to clipboard operation
aws-mobile-appsync-sdk-android copied to clipboard

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

Open admund opened this issue 3 years ago • 1 comments

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):

  • AppSync SDK Version: 3.1.4

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.

admund avatar Jun 11 '21 14:06 admund

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.

ksgangadharan avatar Feb 23 '23 17:02 ksgangadharan