aws-mobile-appsync-sdk-js
aws-mobile-appsync-sdk-js copied to clipboard
useSubscription does not conform to Apollo
The useSubscription hook using the AppSync link does not work correctly. Specifically, it does not implement the onComplete
event which is defined by Apollo documentation. You can reproduce this by simply adding an onComplete
handler to any subscription. This is important because there is no other way know when the subscription has been established. It would be nice to send this event.
I can try to make these changes if somebody could point me in the correct direction in the codebase.
Example:
const { data, loading, error } = useSubscription<TData, TVariables>(
subscription,
{
variables,
onError,
onComplete: () => {
console.log('😵😵😵😵😵😵😵😵😵'); // <---- this never gets called :/
}
}
);
This issue was a major pain to find, after digging through so much documentation on the Apollo side (and the dearth of docs for this project). I need to know when it's okay to send mutations when my logic depends on receiving the update from this subscription. To do that, I need onComplete
. In the meantime, I'm going to have to make my mutation idempotent and re-send it until I see a message come back.
That sounds like a very similar problem. I also noticed that the loading property doesn't really tell us anything in this scenario. It would be great to hear from one of the Amazon engineers who is supporting this project. 🧐