3
votes

I'm using the apollo-server-lambda module to create a lambda that connects to RDS database. The only way I can properly connect to the RDS is the following

    exports.graphqlHandler = function(event, context, callback) { 

     context.callbackWaitsForEmptyEventLoop = false;

     sequelize.authenticate()

    .then(() => {
     console.log('Connection has been established successfully.');
     callback(null, "just stop!");
    })
    .catch(err => {
      console.error('Unable to connect to the database:', err);
      callback("error");
    });

How can I do this using the Apollo server lambda createHandler method

1

1 Answers

2
votes

someone answered my question on github issues.

const server = new ApolloServer({
 context: ({ context, event }) => {
  context. callbackWaitsForEmptyEventLoop = false;
 }
})

https://github.com/apollographql/apollo-server/issues/1479