Skip to content

A console logger link for Apollo Client. Logs request and response of queries and mutations to console.

License

Notifications You must be signed in to change notification settings

FreeWall/apollo-console-logger

Repository files navigation

Apollo Console Logger

npm version publish status

A console logger link for Apollo Client. Logs request and response of queries and mutations to console.

Installation

npm install @freewall/apollo-console-logger

Usage

import { ConsoleLoggerLink } from '@freewall/apollo-console-logger';

const link = ApolloLink.from([
  new ConsoleLoggerLink(),
  new HttpLink({
    uri: '...',
  }),
]);

const client = new ApolloClient({
  link,
  // ...
});

Options

// default values:
new ConsoleLoggerLink({
  colors: {
    query: {
      request: '#E17E00',
      response: '#A65D00',
    },
    mutation: {
      request: '#E10098',
      response: '#A5006F',
    },
  },
  multiline: false,
  responseSize: true,
  responseTime: true,
});

Sample output

image