apollo-newrelic-extension
v0.1.1
Published
Apollo Server extension library for performing NewRelic transaction traces of graphql requests
Downloads
407
Readme
Apollo New Relic Extension
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.
Usage
yarn add apollo-newrelic-extension
- Enable tracing in your
ApolloServer
configuration. - Connect an extension instance to the
ApolloServer
configuration.
Example
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'))