Last active
November 16, 2021 06:11
-
-
Save rajeshkrishnakumar/e66a0e30b667304183d1b4ed268cb8bb to your computer and use it in GitHub Desktop.
newrelic graphQL monitoring middleware
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import newrelic from "newrelic"; | |
/** | |
instead of | |
import newrelic from 'newrelic'; | |
use this if you get error newrelic.setTransactionName is not a function or _newrelic.default.setTransactionName is not a function | |
import newrelic from 'newrelic/index'; | |
**/ | |
const processRequest = async (resolve, root, args, context, info) => { | |
newrelic.setTransactionName(info.fieldName); | |
return resolve(root, args, context, info); | |
}; | |
const graphqlMiddleware = { | |
Query: processRequest, | |
Mutation: processRequest, | |
}; | |
export default graphqlMiddleware; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment