package
Apollo GraphQL Logger
npm install apollo-loggerGitHub-flavored package documentation.
Across all versions, last 30 days.
1,637 in 30 days
Runtime metadata.
Tagged topics.
Estimated unpacked size across 3 packages.
89.6 kB
Includes dependencies.
npm install --save-dev apollo-loggerFor full logging you will need to attach Apollo Logger to:
import { LoggingLink, wrapPubSub, formatResponse } from 'apollo-logger';
const logOptions = { logger: console.log };
const link = ApolloLink.from([
new LoggingLink(logOptions),
new HttpLink({uri: ...})
);
...
app.use('/graphql', bodyParser.json(), graphqlExpress({ schema: myGraphQLSchema, formatResponse: formatResponse.bind(logOptions) });
...
const pubsub = wrapPubSub(new PubSub(), logOptions);On each example the result of operation comes after =>
{"data":{"post":{"id":20,"title":"Post title 20","content":"Post content 20","__typename":"Post","comments":[{"id":39,"content":"Comment title 1 for post 20","__typename":"Comment"},{"id":40,"content":"Comment title 2 for post 20","__typename":"Comment"}]}}} <= post({"id":"20"}){"data":{"addCounter":{"amount":21,"__typename":"Counter"}}} <= addCounter({"amount":1})subscribe <= onPostUpdated({"endCursor":11}){"data":{"counterUpdated":{"amount":21,"__typename":"Counter"}}} <= onCounterUpdatedunsubscribe <= onPostUpdated({"endCursor":11})pubsub publish [ 'countUpdated',
{ id: 1, created_at: null, updated_at: null, amount: 7 } ]pubsub subscribe postsUpdated => 2pubsub unsubscribe [ 2 ]pubsub msg postsUpdated({"mutation":"CREATED","id":21,"node":{"id":21,"title":"New post 1"}})Copyright © 2017 SysGears INC. This source code is licensed under the MIT license.