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?

asked 4 years ago1488 views
2 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 4 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

dmaas
answered 4 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