You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# Put output below this line
Build time: 2021-08-17 09:59:03 UTC
Revision: a773786b58bb28710e3dc96c4d1a7063628952ad
Kotlin: 1.5.21
Groovy: 3.0.8
Ant: Apache Ant(TM) version 1.10.9 compiled on September 27 2020
JVM: 15.0.2 (Oracle Corporation 15.0.2+7-27)
Please include any relevant guides or documentation you're referencing
No response
Describe the bug
If we create a GraphQL schema with some @models, and disable some of the default mutations, DataStore category still tries to subscribe on the disabled mutations.
This behaviour leads to an error when performing any operation, because of the server rejecting the subscription.
There is a `@model` called `PerformedBlockItem` in our schema.
When I query, regardless of the queried model type, a similar error to this is thrown:
E/amplify:aws-datastore: Failure encountered while attempting to start API sync.
GraphQLResponseException{message=Subscription error for PerformedBlockItem: [GraphQLResponse.Error{message='Validation error of type FieldUndefined: Field 'onCreatePerformedBlockItem' in type 'Subscription' is undefined @ 'onCreatePerformedBlockItem'', locations='null', path='null', extensions='null'}], errors=[GraphQLResponse.Error{message='Validation error of type FieldUndefined: Field 'onCreatePerformedBlockItem' in type 'Subscription' is undefined @ 'onCreatePerformedBlockItem'', locations='null', path='null', extensions='null'}], recoverySuggestion=See attached list of GraphQLResponse.Error objects.}
at com.amplifyframework.datastore.appsync.AppSyncClient.lambda$subscription$2(AppSyncClient.java:321)
at com.amplifyframework.datastore.appsync.AppSyncClient$$ExternalSyntheticLambda5.accept(Unknown Source:8)
at com.amplifyframework.api.aws.SubscriptionEndpoint$Subscription.dispatchNextMessage(SubscriptionEndpoint.java:414)
at com.amplifyframework.api.aws.SubscriptionEndpoint.notifySubscriptionData(SubscriptionEndpoint.java:248)
at com.amplifyframework.api.aws.SubscriptionEndpoint.access$700(SubscriptionEndpoint.java:61)
at com.amplifyframework.api.aws.SubscriptionEndpoint$AmplifyWebSocketListener.processJsonMessage(SubscriptionEndpoint.java:592)
at com.amplifyframework.api.aws.SubscriptionEndpoint$AmplifyWebSocketListener.onMessage(SubscriptionEndpoint.java:498)
This also happens when mutations is not null but contains only some of the mutations.
After compilation, the schema's Subscription part doesn't contain any subscription for our model.
Additional information and screenshots
As a workaround, I can let amplify generate all mutations (and all subscriptions), and block access to those I'm no interested in by permissions, but this is a really bad behavior I would like to avoid of course.
It creates requests for all subscriptions regardless of which mutation really exists.
I also saw the same behavior in Amplify for JS. Maybe it's intentional for some reason.
Anyway It would be great if we can discuss this or find a solution.
The text was updated successfully, but these errors were encountered:
Did you disable the subscription as well? What was your mechanism to disable mutation?
Thank you for your response!
The subscription is not generated in the first place if you disable the mutation.
I disabled the mutation by adding mutations: null into the @model definition in my schema (which is attached in the original question above).
Tried also subscriptions: null but Android seems to ignore those definitions when it tries to subscribe (see the attached code snippet).
Trying to understand the use case here, what is the point of disabling the default mutations? If there are no mutations how will you update the datastore?
Before opening, please confirm:
Language and Async Model
Kotlin - Coroutines
Amplify Categories
DataStore
Gradle script dependencies
Environment information
Please include any relevant guides or documentation you're referencing
No response
Describe the bug
If we create a GraphQL schema with some
@model
s, and disable some of the default mutations,DataStore
category still tries to subscribe on the disabled mutations.This behaviour leads to an error when performing any operation, because of the server rejecting the subscription.
Reproduction steps (if applicable)
Code Snippet
Log output
amplifyconfiguration.json
No response
GraphQL Schema
This also happens when mutations is not null but contains only some of the mutations.
After compilation, the schema's
Subscription
part doesn't contain any subscription for our model.Additional information and screenshots
As a workaround, I can let amplify generate all mutations (and all subscriptions), and block access to those I'm no interested in by permissions, but this is a really bad behavior I would like to avoid of course.
Code-wise:
I've seen in
amplify-android/aws-datastore/src/main/java/com/amplifyframework/datastore/syncengine/SubscriptionProcessor.java
Lines 119 to 134 in ca1be48
It creates requests for all subscriptions regardless of which mutation really exists.
I also saw the same behavior in Amplify for JS. Maybe it's intentional for some reason.
Anyway It would be great if we can discuss this or find a solution.
The text was updated successfully, but these errors were encountered: