apollo-server-integrations / apollo-server-integration-aws-lambda

An integration to use AWS Lambda as a hosting service with Apollo Server
MIT License
46 stars 9 forks source link

How to send cookies from within Resolvers #84

Closed Nosherwan closed 1 year ago

Nosherwan commented 1 year ago

I would like to be able to send cookies from resolvers, example as below:

const _baseCookie = (expires: Date) => ({
    sameSite: 'strict',
    expires,
    overwrite: true,
    domain,
});

export const resolvers = {
    Query: {
        logout: async (_: any, _resp: any, {  res }: any) => {
            const expires = new Date('1970');

            const baseCookie = _baseCookie(expires);

            res.cookie('auth', '', { ...baseCookie, signed: true });
            res.cookie('info', '', { ...baseCookie, httpOnly: false });
        },
BlenderDude commented 1 year ago

Please take a look at #91 and let me know your feedback on this new functionality. It will allow you to update the result based on the contextValue.