Using DynamoDB and RDS Together

Im using graphql serverless architecture and I want to first get which projects a user has access to through dynamoDB and then using that array of values, query access a postgres database according to the returned values.

I can’t seem to get it to work no matter the structure of my code. As of now, I’m invoking a lambda function that queries the users table in Dynamo and then tries to use the projects array.

  Query: {
    getItems: (parent, args, { event }) => {
        { FunctionName: 'function-queries-dynamo' },
        (err, results) => {
          return knex('items')
            .whereIn('projectId', results.Items[0].projects)
            .then(itemList => {
              return itemList

DynamoDB returns out of the function correctly and then the RDS call also returns the correct filtered data from the table. But the query returned is not in the format expected by lambda/graphQL so maybe this is more a javascript issue.

There are a couple things that look wrong to me.

getItems: (parent, args, { event }) => {
  // You need an explicit `return` here because you're using a code block.

Add return lambda.invoke() also won’t work because lambda.invoke() will return immediately. You probably want to have a read of