@lightspeed/apollo-logging-extension
v0.2.13
Published
Standard output logging extension for Apollo GraphQL services
Downloads
59
Keywords
Readme
@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.
// server.ts
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:
// server.ts
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,
});