Created
March 21, 2023 15:50
-
-
Save PatrikValkovic/9a03bcf547c0b0271cc8aa3ae00ac7a6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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