Registry / devops / apollo-logger

apollo-logger

JSON →
library0.3.3jsnpmunverified

Apollo Logger is a utility for logging Apollo GraphQL operations, including queries, mutations, subscriptions, and PubSub events. Current version is 0.3.3. The package has low release cadence (last release in 2018). Key differentiators: it provides multiple entry points (LoggingLink for Apollo Link, wrapPubSub for PubSub, formatResponse for Express) to log the full lifecycle of GraphQL requests. It is unmaintained and should be considered for deprecation in favor of modern alternatives like Apollo Server plugins.

npm install apollo-logger
INSTALL
IMPORT
SIG · APOLLO-LOGGER
A
apollo-logger
devopsjavascriptv0.3.3
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

LoggingLink
import { LoggingLink } from 'apollo-logger';
const LoggingLink = require('apollo-logger').LoggingLink;
ESM only; package does not support CommonJS require directly.
wrapPubSub
import { wrapPubSub } from 'apollo-logger';
const { wrapPubSub } = require('apollo-logger');
ESM only; avoid destructuring require.
formatResponse
import { formatResponse } from 'apollo-logger';
import { formatResponse } from 'apollo-logger/formatResponse';
Export is from main entry; no subpath export exists.

Shows how to set up logging for Apollo Link, Express server, and PubSub using Apollo Logger.

import { LoggingLink, wrapPubSub, formatResponse } from 'apollo-logger'; import { ApolloLink, HttpLink } from 'apollo-link'; import { PubSub } from 'graphql-subscriptions'; import express from 'express'; import { graphqlExpress } from 'apollo-server-express'; const logOptions = { logger: console.log }; const link = ApolloLink.from([ new LoggingLink(logOptions), new HttpLink({ uri: '/graphql' }) ]); const app = express(); app.use('/graphql', graphqlExpress({ schema: myGraphQLSchema, formatResponse: formatResponse.bind(logOptions) })); const pubsub = new PubSub(); const wrappedPubSub = wrapPubSub(pubsub, logOptions); app.listen(4000, () => console.log('Server running on port 4000'));
Debug
Known issues
deprecatedPackage is unmaintained since 2018. No updates for modern Apollo Link v2 or Apollo Server v3+.
fix
Consider using Apollo Server built-in plugins or custom logging solutions.
affects: >=0.3.3
gotchaformatResponse expects `this` context bound to logOptions. If not bound, logging may fail.
fix
Use formatResponse.bind(logOptions) when passing to apollo-server-express.
affects: *
gotchawrapPubSub modifies the original PubSub instance in-place; do not use the original after wrapping.
fix
Store the returned wrapped instance and use that for all PubSub operations.
affects: *
gotchaPeer dependencies (apollo-link, graphql-subscriptions, graphql, iterall) must be manually installed; not bundled.
fix
Run: npm install apollo-link graphql-subscriptions graphql iterall
affects: *
Errors
Common errors & fixes
TypeError: Cannot read property 'logger' of undefined
formatResponse called without proper this context binding.
fix
Use formatResponse.bind(logOptions) when passing to graphqlExpress.
Module not found: Can't resolve 'apollo-link'
Missing peer dependency apollo-link.
fix
Run: npm install apollo-link
TypeError: PubSub.wrapPubSub is not a function
Incorrect import of wrapPubSub; may be using default import instead of named.
fix
Use: import { wrapPubSub } from 'apollo-logger';
Upgrade
Version history
0.3.3latest on npm
Audit
Dependencies
apollo-linkrequiredPeer dependency required for LoggingLink
graphqlrequiredPeer dependency for GraphQL schema and operations
graphql-subscriptionsrequiredPeer dependency for wrapPubSub
iterallrequiredPeer dependency for iteration utilities
Agent activity
28 hits · last 30 days
node
24
OpenAI (training)
1
Resources
apollo-logger — npm install apollo-logger · libregistry