-
Notifications
You must be signed in to change notification settings - Fork 52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FR - Middleware to log queries to a another repository #88
Comments
You can implement this with a query resolve hook. |
Thanks. Including @sibeliusseraphini. |
@rturk Trust me, it's not so hard to implement these in resolve hooks: const hooks = {
plural: {
pre: (next, root, args, context) => {
context.rootValue.startTime = Date.now();
},
post: (next, value, args, asd, context) => {
// 1) Query text
const { query, variables } = context.rootValue.body // I need to add the body to rootValue in `graffiti`, you can open a PR too
// 2) Execution time
const executionTime = Date.now() - context.rootValue.startTime;
// 3) Date
const date = Date.now()
// 4) Request source (IP, Auth code, etc)
const { headers } = context.rootValue
// 5) Info about required nodes
const { fieldName, fieldASTs } = context
// 6) Filter defines what queries will be logged or not
if (/* custom filter */.filter(context)) {
// save
}
}
}
};
const schema = getSchema([/* models */], { hooks }); |
@tothandras tks! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Feature request: Log queries to a database
The text was updated successfully, but these errors were encountered: