graphql中的Console.log解析器数据 [英] Console.log resolver data in graphql
问题描述
我正在尝试在graphql应用程序中console.log解析器.graphiql部分可以正常工作(我可以启动服务器并查看graphql仪表板,然后使用根查询在浏览器窗格中检索结果),但是无法控制台.在我的浏览器控制台中记录相同的结果.以下是我的代码:
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));
});
});
}
};
不起作用"的部分是代码的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?
推荐答案
您使用的 console.log
不在客户端.
它将结果记录在服务器端,而不是浏览器上.检查启动GraphQL服务器的命令行,日志应该在那里.
It logs the result on the server side, not on the browser. Check your command line that started the GraphQL server, the logs should be there.
这篇关于graphql中的Console.log解析器数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!