I'm trying to console.log the resolver in a graphql app. The graphiql part works (I can start the server and see the graphql dashboard and then use the root query to retrieve the results in the browser pane), but I'm unable to console.log the same results in my browser console. Following is my code:
const GetBooks = {
type: new GraphQLList(BookTypes),
args: {},
resolve() {
return new Promise((resolve, reject) => {
let sql = singleLineString`
select * from books
`;
sql = mysql.format(sql);
pool.query(sql, (err, results) => {
if (err) {
reject(err);
}
resolve(results);
console.log(resolve(results));
});
});
}
};
The part that is 'not working' is the console.log(resolve(results)) part of the code. Can someone point out why this isn't working?