Skip to content

Instantly share code, notes, and snippets.

@timjbray
Last active March 17, 2019 09:33
Show Gist options
  • Save timjbray/b9aca6843d7c4ebb89ebca7f739111b4 to your computer and use it in GitHub Desktop.
Save timjbray/b9aca6843d7c4ebb89ebca7f739111b4 to your computer and use it in GitHub Desktop.
const server = new ApolloServer({
typeDefs,
resolvers,
context: graphQLContext,
formatError: (error: any) => {
// filter whatever errors your don't want to log
logger.error(`[GraphQL.error] ${error.message}`, error);
return error;
},
formatResponse: (response: any) => {
// don't auth mutations or schema requests
const name = Object.keys(get(response, 'data') || { unknown: 0 })[0];
if (!['authSignIn', 'authRefreshToken', '__schema', ... ].includes(name)) {
logger.debug(`[GraphQL.response] ${name}()`, response);
}
return response;
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment