AWS AppSync Subscriptions #1323
-
Hello, I'm evaluating Urql for use with AppSync graph service and I have a question regarding Exchanges. AWS expects the following payload:
Many graphql clients and are expecting the query in a
Is there any issue with this approach? I want to make sure this falls within the responsibility of the Exchange function and will not cause issues with urql cache. Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
No, this approach shouldn't impose an issue as long as the responses follow the regular GraphQL spec. |
Beta Was this translation helpful? Give feedback.
-
I tested a different approach in which I am using Amazon Amplify's GraphQL client to perform the subscription and therefore I do not need to write custom code that is compatible with the transport protocol used by AWS AppSync: import { API, graphqlOperation } from "aws-amplify";
import { subscriptionExchange } from "urql";
function forwardSubscription(operation) {
return {
subscribe: (sink) => {
return;
API.graphql(
graphqlOperation(operation.query, operation.variables)
).subscribe({
next: ({ value: { data } }) => {
sink.next({ data });
},
error: (error) => {
sink.error(error);
},
});
},
};
}
const subscriptionExchangeInstance = subscriptionExchange({
forwardSubscription,
}); |
Beta Was this translation helpful? Give feedback.
No, this approach shouldn't impose an issue as long as the responses follow the regular GraphQL spec.