-
Notifications
You must be signed in to change notification settings - Fork 130
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Subscriptions can fail depending on source mutation return parameters #216
Comments
Hello @airstance This is a service requirement from what I can tell. The subscription can only get data which was specified in the mutation. Subscription data can be a subset of mutation selections, but not a super set. You will have to select the right fields in mutation for subscriptions to function correctly. Thanks, |
When publishing a GraphQL interface to outside developers, I have to ask them to make sure they include a minimum set of return parameters, otherwise, they'll cause some subscriptions to fail. That doesn't seem very robust. I understand there's nothing the iOS client can do about the response. I'll probably ask for a feature request for the AppSync service to add the ability to create response resolvers for handling subscription clients. To work around this limitation, I first tried to re-create the GraphQL types and made all required fields optional. That would allow the client subscription validation work and at least pass me what fields were supplied. Right now I get nothing. That worked great, but then I realized this didn't really help me because I sometimes still had an error condition (missing data) that I could do nothing about. In the end, I called the modified syncNow() method (#215) in the subscription handlers if there were missing parameters. That allows the delta catch-up sync code to catch the offending mutation changes. |
The original bug report is also happening to us. We have a subscription to our entity, we'll call it I definitely think you should be able to return a subset of fields rather than have to return all fields(and sub selections) defined in the graph. |
@rohandubal I think there's a bug here. I can post any additional information necessary |
I think this could be argued as buggy behavior--it's certainly unexpected--but the behavior is by design on the service. We'll ask the service team to investigate this and post a reply when we have an update. In the meantime, we'll also investigate #215 to see if there's a mitigation on the client side that we can apply without impacting other behaviors. |
Here's the Crashlytics raw text if it helps: This still appears to be happening even after adjusting the return parameters on the server, so our "workaround" doesn't appear to be viable at this point either.
|
@airstance Did this PR #259 fix your issue? |
Closing old issue. There's not a good workaround here--the strongly-typed return values expect values in required fields, and if those values aren't in the mutation's selection set, then the subscription won't have them and will deliver a partial result. In Amplify DataStore, we carefully craft mutations with fully-populated selection sets so that subscriptions are delivered as expected. As any change to this behavior would need to be handled on the service, so I'm closing this client-side issue. |
My subscription handler is being called with an error.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
The getPost call works when only the id is requested. I would expect the same here. The subscription handler should be called with as many fields as are available.
Environment(please complete the following information):
Additional context
On a related note, it seems very odd that the subscription handler is only called with the result parameters for the mutation. If the mutation call only asks for minimal data, i would be forced to make a manual fetch call for the object. Even that won't work if the mutation request does not ask for all the return parameters necessary to make the manual fetch. I apologize in advance for my lack of knowledge of AppSync subscriptions.
The text was updated successfully, but these errors were encountered: