【发布时间】:2019-03-28 01:51:31
【问题描述】:
我正在尝试在 graphql 应用程序中控制台记录解析器。 graphiql 部分有效(我可以启动服务器并查看 graphql 仪表板,然后使用根查询在浏览器窗格中检索结果),但我无法在浏览器控制台中 console.log 相同的结果。以下是我的代码:
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));
});
});
}
};
“不起作用”的部分是代码的 console.log(resolve(results)) 部分。有人能指出为什么这不起作用吗?
【问题讨论】:
标签: graphql