Node.js 如何使用graphql对日志进行精确查询?
我想检索每个查询/变异并将其放入日志中:Node.js 如何使用graphql对日志进行精确查询?,node.js,graphql,apollo,Node.js,Graphql,Apollo,我想检索每个查询/变异并将其放入日志中: .... const server = new ApolloServer({ typeDefs: typeDefs, resolvers: [query, mutation, tables], debug: DEBUG, context: params => () => { return f.context(params); }, .... 在我的上下文函数中,我有: function context(param
....
const server = new ApolloServer({
typeDefs: typeDefs,
resolvers: [query, mutation, tables],
debug: DEBUG,
context: params => () => {
return f.context(params);
},
....
在我的上下文函数中,我有:
function context(params) {
....
let query = params.req.body.query;
...
}
问题是:params.req.body.query等于body中的所有查询,而不是执行的查询
例如,如果在graphiQL中我有:
mutation a {
createElement(...) {
...
}
}
mutation b {
updateElement(...) {
...
}
}
mutation c {
deleteElement(...)
}
无论使用何种突变,我都会在日志中收到完全相同的结果
所以我的问题是:是否有可能只获取执行的查询 你可以用一只手来做这件事。如果您想将其与阿波罗服务器一起使用,请看一看,您可以使用一个。如果你想用它与阿波罗服务器有一个看