By using AWS re:Post, you agree to the Terms of Use
/AWS App Sync Subscriptions over apollo-link-ws/

AWS App Sync Subscriptions over apollo-link-ws

0

I am trying to setup the Apollo Client without using the JavaScript AWS AppSync Client. I understand that it would be easiest to just use the JS AppSync Client since I am already using AppSync but I am trying to avoid using AWS libraries in my client. Also, it doesn't seem to work well with graphql-codegen.

I can connect and start the GraphQL handshake via Apollo which produces the following messages:

Sent: {"type":"connection_init","payload":{}}
Sent: {"id":"1","type":"start","payload":{"variables":{"sessionID":"659d86ae-ec0c-4170-9866-b436a981ce29"},"extensions":{},"operationName":"ParticipantJoined","query":"subscription ParticipantJoined($sessionID: ID!) {\n  participantJoinedSession(id: $sessionID) {\n    id\n    name\n    participants {\n      name\n      vote {\n        points\n        abstained\n        __typename\n      }\n      __typename\n    }\n    __typename\n  }\n}\n"}}
Received: {"type":"connection_ack","payload":{"connectionTimeoutMs":300000}}
Received: {"type":"ka"}

But then I receive the following error:

{"type":"error","id":"","payload":{"errors":[{"errorType":"UnsupportedOperation","message":"unknown not supported through the realtime channel"}]}}

I noticed that the JS AppSync library appears to be sending the connection_init message without a payload, but other than that I see no other potential problem/mistake.

What could this error be referring to?

3 Answers
0

I seem to have answered my own question.

AWS is expecting a query payload that does not follow the shape of the subscription-transport-ws library. Instead, it expects something like this.

{"id":"1","type":"start","payload":{"variables":{"sessionID":"659d86ae-ec0c-4170-9866-b436a981ce29"},"extensions":{"authorization":{"host":"fev5xxdscnesvifqf45rj3zsl4.appsync-api.us-east-2.amazonaws.com","x-amz-user-agent":"aws-amplify/2.0.1","x-api-key":"da2-jdwemepvzbeo5okdsfokyqdmtq"}},"operationName":"ParticipantJoined","query":"subscription ParticipantJoined($sessionID: ID!) {\n  participantJoinedSession(id: $sessionID) {\n    id\n    name\n    participants {\n      name\n      vote {\n        points\n        abstained\n        __typename\n      }\n      __typename\n    }\n    __typename\n  }\n}\n","data":"{\"variables\":{\"sessionID\":\"659d86ae-ec0c-4170-9866-b436a981ce29\"},\"extensions\":{},\"operationName\":\"ParticipantJoined\",\"query\":\"subscription ParticipantJoined($sessionID: ID!) {n  participantJoinedSession(id: $sessionID) {n    idn    namen    participants {n      namen      vote {n        pointsn        abstainedn        __typenamen      }n      __typenamen    }n    __typenamen  }n}n\"}"}}

Furthermore, app sync returns a start_ack message type which is not part of subscription-transport-ws' lifecycle events.

answered 2 years ago
0

I am trying to setup identically the same as you did, namely using AWS AppSync with Apollo Client without aws-appsync-js-sdk. I manage to make the connection, however I still get this exact same error message with my custom implementation:

errorType: "UnsupportedOperation", message: "unknown not supported through the realtime channel"

my message looks like this:

      {"id":1590753875626,"payload":{"data":"{\"query\":\"n        subscription {n          ballUpdated {n            xn            yn            __typenamen          }n        }n      \",\"variables\":{}}","extensions":{"authorization":{"host":"xxxxxx.appsync-api.us-east-2.amazonaws.com","x-api-key":"xxxxxxxxxx"}}},"type":"start"}

I am trying to set this up via this article with javascript:
https://aws.amazon.com/blogs/mobile/appsync-websockets-python/

Did you manage to make it work? I would really appreciate if you could point out what I am doing wrong, I have gone through it 10 times already.

Thanks in advance!

Edited by: f4z3k4s on May 29, 2020 5:15 AM

answered 2 years ago
0

To get AppSync Subscriptions working with subscription-transport-ws, you need to follow the instructions in this GitHub issue: https://github.com/apollographql/apollo-feature-requests/issues/224

answered 2 years 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.

Guidelines for Answering Questions