3232import com .amplifyframework .datastore .AmplifyDisposables ;
3333import com .amplifyframework .datastore .DataStoreChannelEventName ;
3434import com .amplifyframework .datastore .DataStoreException ;
35+ import com .amplifyframework .datastore .DataStoreException .GraphQLResponseException ;
3536import com .amplifyframework .datastore .appsync .AppSync ;
3637import com .amplifyframework .datastore .appsync .AppSyncExtensions ;
38+ import com .amplifyframework .datastore .appsync .AppSyncExtensions .AppSyncErrorType ;
3739import com .amplifyframework .datastore .appsync .ModelWithMetadata ;
3840import com .amplifyframework .datastore .appsync .SerializedModel ;
3941import com .amplifyframework .hub .HubChannel ;
@@ -155,15 +157,15 @@ synchronized void startSubscriptions() throws DataStoreException {
155157 }
156158 }
157159
158- private boolean isUnauthorizedException (DataStoreException exception ) {
159- if (exception instanceof DataStoreException . GraphQLResponseException ) {
160- List <GraphQLResponse .Error > errors = ((DataStoreException . GraphQLResponseException ) exception ).getErrors ();
160+ private boolean isExceptionType (DataStoreException exception , AppSyncErrorType errorType ) {
161+ if (exception instanceof GraphQLResponseException ) {
162+ List <GraphQLResponse .Error > errors = ((GraphQLResponseException ) exception ).getErrors ();
161163 GraphQLResponse .Error firstError = errors .get (0 );
162164 if (Empty .check (firstError .getExtensions ())) {
163165 return false ;
164166 }
165167 AppSyncExtensions extensions = new AppSyncExtensions (firstError .getExtensions ());
166- return AppSyncExtensions . AppSyncErrorType . UNAUTHORIZED .equals (extensions .getErrorType ());
168+ return errorType .equals (extensions .getErrorType ());
167169 }
168170 return false ;
169171 }
@@ -186,11 +188,17 @@ private boolean isUnauthorizedException(DataStoreException exception) {
186188 },
187189 emitter ::onNext ,
188190 dataStoreException -> {
189- // Ignore Unauthorized errors, so that DataStore can still be used even if the user is only
190- // authorized to read a subset of the models.
191- if ( isUnauthorizedException ( dataStoreException )) {
191+ if ( isExceptionType ( dataStoreException , AppSyncErrorType . UNAUTHORIZED )) {
192+ // Ignore Unauthorized errors, so that DataStore can still be used even if the user is only
193+ // authorized to read a subset of the models.
192194 latch .countDown ();
193- LOG .warn ("Unauthorized failure for " + subscriptionType .name () + " " + modelSchema .getName ());
195+ LOG .warn ("Unauthorized failure:" + subscriptionType .name () + " " + modelSchema .getName ());
196+ } else if (isExceptionType (dataStoreException , AppSyncErrorType .OPERATION_DISABLED )) {
197+ // Ignore OperationDisabled errors, so that DataStore can be used even without subscriptions.
198+ // This logic is only in place to address a specific use case, and should not be used without
199+ // unless you have consulted with AWS. It is subject to be deprecated/removed in the future.
200+ latch .countDown ();
201+ LOG .warn ("Operation disabled:" + subscriptionType .name () + " " + modelSchema .getName ());
194202 } else {
195203 if (latch .getCount () > 0 ) {
196204 // An error occurred during startup. Abort and notify the Orchestrator by throwing the
0 commit comments