Creates a newrelic transaction with associated custom attributes on each graphql request/response. For use with Apollo Server's experimental extensions API only available with Apollo Server >= 2.x.
yarn add apollo-newrelic-extension
- Enable tracing in your
ApolloServer
configuration. - Connect an extension instance to the
ApolloServer
configuration.
const express = require('express')
const { ApolloServer } = require('apollo-server-express')
const ApolloNewrelicExtension = require('apollo-newrelic-extension')
const typeDefs = require('./typeDefs')
const resolvers = require('./resolvers')
const server = new ApolloServer({
typeDefs,
resolvers,
// ...additional configuration...
// Thunk for creating the newrelic extension
extensions: [() => new ApolloNewrelicExtension()],
// Be sure to enable tracing
tracing: true
})
const app = express()
server.applyMiddleware({ app })
app.listen(3000, () => console.log('Server listening on port 3000'))