How to configure Aws Amplify for a AppSync subscription Websocket endpoint?

Viewed 1163

How do I specify a websocket endpoint using Amplify.configure(awsConfig) The docs only demonstrate how to do a singular http endpoint using the aws_appsync_graphqlEndpoint

AWS Amplify.configure docs.

I have separate appsync urls one is a "realtime" websocket url.

REACT_APP_GRAPHQL_ENDPOINT_HTTP
REACT_APP_GRAPHQL_ENDPOINT_WS

I am trying to connect to AppSync with the AWS Amplify SDK using the Amplify graphql subscriptions

2 Answers

I discovered that aws-amplify will automatically configure the websocket endpoint based on the http endpoint when you use Amplify.configure(awsConfig). Did not see this mentioned any where and is a bit magical.

It will autogenerate subscription .. Also If you are using GraphQl schema then you can do like this @model(queries: { get: "getUser", list: "listUsers" }, subscriptions: null)

Related