Skip to content

Instantly share code, notes, and snippets.

@PatrikValkovic
Last active March 24, 2023 13:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PatrikValkovic/57deaacade44ff6dfbffe09ad2577211 to your computer and use it in GitHub Desktop.
Save PatrikValkovic/57deaacade44ff6dfbffe09ad2577211 to your computer and use it in GitHub Desktop.
export const handler = async (event: SQSEvent) => {
const body = JSON.parse(event.body);
const subscriptions = await subscriptionRepository.getByRoutingKey(body.routingKey);
for(subscription of subscriptions) {
const document = parse(subscription.subscription);
const subscriptionResult = await subscribe({
schema,
document,
variableValues: subscription.variables,
contextValue: contextDeserializer(subscription.context),
});
do {
const next = await result.next();
await client.send(subscription.connectionId, next.value);
} while (!next.done);
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment