Skip to content

does aws-appsync-subscription-link contain websocket

0

I am using aws-appsync-subscription-link as dependency to enable apollo graphql subscription. Do I need to explicitly download npm install graphql-ws?

asked a year ago307 views
1 Answer
0

Yes, the aws-appsync-subscription-link package does contain WebSocket functionality for GraphQL subscriptions in AWS AppSync. However, you do not need to explicitly install graphql-ws separately.

AWS AppSync has transitioned to using pure WebSockets for GraphQL subscriptions, moving away from the older MQTT over WebSockets protocol. The aws-appsync-subscription-link package, which is part of the AWS AppSync SDK for JavaScript, automatically handles the WebSocket connection for you.

If you're using a recent version of the AWS AppSync SDK (version 3.0.2 or later) or Amplify clients (version 2.1.0 or later), these libraries automatically use pure WebSockets for subscriptions by default. This means you don't need to install any additional WebSocket-specific packages like graphql-ws.

The AWS AppSync SDK takes care of establishing and maintaining the secure WebSocket connection, handling the subscription workflow, and managing the communication between your client and the AppSync service. This includes tasks such as connection initialization, subscription registration, receiving subscription events, and maintaining the connection with keep-alive messages.

By using aws-appsync-subscription-link, you're already set up to use WebSockets for your GraphQL subscriptions in AWS AppSync without any additional installations or configurations.

Additionally, you can go through the below example provided for using subscription with the aws-appsync-subscription-link package :

Sources
AWS AppSync adds Real-Time enhancements with Pure WebSockets support for GraphQL Subscriptions
Building a real-time WebSocket client in AWS AppSync - AWS AppSync

answered a year ago
AWS
SUPPORT ENGINEER
revised a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.