Feature Request - enable PubSub to work along side GraphQL/Appsync
Having a REST API, I added PubSub and observed the expected PubSub functionality when unauthenticated, and after adding both IAM and IOT policies and attaching the Cognito ID of each subscriber, I also observed expected PubSub functionality when authenticated.
Having upgraded from REST to AppSync/GraphQL, I observe the desired Query and Mutation behaviour. Despite many subscription/authorization patterns available, as far as I can tell the GraphQL subscription mechanism will not be flexible enough to meet my authorization needs.
In order to meet my needs, I returned to the more generic PubSub. But I have discovered that under the same PubSub configuration, the PubSub functionality that worked along side REST no longer works along side GraphQL. I suspect that Amplify PubSub and Amplify API GraphQL have contention in using the same MQTT/WebSocket resources.
I have the correct PubSub configuration:
Amplify.addPluggable(
new AWSIoTProvider({
aws_pubsub_region: <my region>
aws_pubsub_endpoint: <my endpoint>
})
);
With GraphQL (but not with REST) subscribing to a PubSub Topic results in this error:
Error: Missing connections info
at AWSAppSyncProvider../node_modules/aws-amplify/lib/PubSub/Providers/AWSAppSyncProvider.js.AWSAppSyncProvider.subscribe (AWSAppSyncProvider.js:75)
Any update on this? Everything works fine with PubSub when there is no GraphQL added via Amplify. However when using GraphQL and using:
Amplify.addPluggable(
new AWSIoTProvider({
aws_pubsub_region: "eu-west-1",
aws_pubsub_endpoint:
"wss://<yourstuff>.iot.eu-west-1.amazonaws.com/mqtt"
})
);
It results in a missing connections info error.
Bruh, this issue is still unsolved... I may have to roll up my sleeves real soon. I was hoping someone would have done the dirty work by now.
I can confirm that:
Perhaps they are fighting for the same socket resource which doesnt allow for them to simultaneously use them.
this is the line that's producing the error in AWSAppSyncProvider.js
:
newAliases = Object.entries(newSubscriptions)
It appears that AppSync is the one that's breaking because of AWS IOT.
The code in IOT that causes AppSync to break is:
PubSub.subscribe("rice").subscribe({})
when setting up a pubsub connection.
@Matthcw we are working on it. @manueliglesias will work on this.
Most helpful comment
Any update on this? Everything works fine with PubSub when there is no GraphQL added via Amplify. However when using GraphQL and using:
Amplify.addPluggable( new AWSIoTProvider({ aws_pubsub_region: "eu-west-1", aws_pubsub_endpoint: "wss://<yourstuff>.iot.eu-west-1.amazonaws.com/mqtt" }) );
It results in a missing connections info error.