我正在尝试在 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));
});
});
}
};
Run Code Online (Sandbox Code Playgroud)
“不起作用”的部分是代码的 console.log(resolve(results)) 部分。有人可以指出为什么这不起作用吗?
您console.log正在使用的不在客户端。
它将结果记录在服务器端,而不是浏览器上。检查启动 GraphQL 服务器的命令行,日志应该在那里。
| 归档时间: |
|
| 查看次数: |
3618 次 |
| 最近记录: |