PLEASE NOTE: This package is still experimental and the API will most likely change.
Installation
yarn add @kiwicom/graphql-logz
Usage
You have to set LOGZIO_TOKEN
environment variable. Then just call the recordRequest
function somewhere in your application (end of life-cycle):
import Logger from '@kiwicom/graphql-logz';
const logger = new Logger({
origin: 'service-name.kiwi.com', // required
logzioToken: process.env.LOGZIO_TOKEN, // required
});
// to this as soon as possible (first middleware for example)
const startAt = process.hrtime.bigint();
// ...
logger.recordRequest({
query: '{ __typename }',
variables: {},
operationName: undefined,
result: {
data: {
__typename: 'RootQuery',
},
},
startAt,
});
Logging deprecated fields
You are going to need @kiwicom/graphql-resolve-wrapper
for this. This package will allow you to wrap the resolvers and do whatever you want to do:
function wrapper(resolveFn, field) {
return (parent, args, context, info) => {
logger.recordDeprecatedField(field, info ? info.path : null);
return resolveFn(parent, args, context, info);
};
}
wrapResolvers(Schema, wrapper);