@lightspeed/apollo-logging-extension
Introduction
Standard output logging extension for GraphQL services. Logs the request operation, query, arguments, errors, and tracing information overall and per field.
Quick Start
- Install the dependency in your webapp.
yarn add apollo-server-express @lightspeed/apollo-logging-extension
- Enable the extension and tracing in your Apollo server configuration. As a best practice, pass in the version and name of your service.
import ApolloLoggingExtension from '@lightspeed/apollo-logging-extension';
const { name, version } = require('./package.json');
const server = new ApolloServer({
extensions: [() => new ApolloLoggingExtension({ name, version })],
tracing: true,
});
- Optionally, enable variables logging for debugging purpose. This is explicitely turned off by default to prevent logging sensible information going through the GraphQL layer:
import ApolloLoggingExtension from '@lightspeed/apollo-logging-extension';
const { name, version } = require('./package.json');
const server = new ApolloServer({
extensions: [
() =>
new ApolloLoggingExtension({
name,
version,
logVariables: process.env.NODE_CONFIG_ENV === 'development',
}),
],
tracing: true,
});