Skip to content

Instantly share code, notes, and snippets.

@PatrikValkovic
Created March 21, 2023 15:50
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/9a03bcf547c0b0271cc8aa3ae00ac7a6 to your computer and use it in GitHub Desktop.
Save PatrikValkovic/9a03bcf547c0b0271cc8aa3ae00ac7a6 to your computer and use it in GitHub Desktop.
export const handler = async (event: APIGatewayEvent): Promise<APIGatewayResult> => {
const body = JSON.parse(event.body);
// ...
if (body.type === 'subscribe') {
const parsed = parse(body.payload.query);
const validated = validate(schema, parsed);
if (validated.length > 0)
await connection.send(event.requestContext.connectionId, { errors: validated });
await subscribe({
schema,
document: parsed,
variableValues: body.payload.variables,
contextValue: createSubscriptionContext(event),
});
return ok();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment