我正在尝试在 graphql 应用程序中 console.log 解析器。 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)) 部分。有人可以指出为什么这不起作用吗?
The console.log
您使用的不是在客户端。
它将结果记录在服务器端,而不是浏览器上。检查启动 GraphQL 服务器的命令行,日志应该在那里。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)