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 }) => {
lambda.invoke(
{ 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.