Don't get me wrong I have been forced to use waterfall because I need to execute one function after another. There is no problem related to the schema or return type just stuck with asynchronous waterfall. All I need is to return from the final function not before.
const async = require('async')
module.exports = {
logout : ()=>{
return async.waterfall([
callback => {
setTimeout(() => {
let data = 1;
return callback(null, data)
}, 2000);
},
(data, callback) => {
setTimeout(() => {
return callback(null, data+1)
}, 2000);
}
], (err, res)=>{
console.log(res)
return res
})
}
}
response from graphiql because It returns early. And console.log is working
{
"errors": [
{
"message": "Cannot return null for non-nullable field RootMutation.logout.",
"locations": [
{
"line": 4,
"column": 3
}
],
"path": [
"logout"
]
}
],
"data": null
}