From 16467d4a194bc95e0f507d0cffb90cb628601eef Mon Sep 17 00:00:00 2001 From: Avior Date: Fri, 31 Dec 2021 00:11:53 +0100 Subject: [PATCH] refactor: Add more logging forGraphQL errors (#218) --- server/src/V2/graphql/index.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/server/src/V2/graphql/index.ts b/server/src/V2/graphql/index.ts index d04b4c30a..0779e8f12 100644 --- a/server/src/V2/graphql/index.ts +++ b/server/src/V2/graphql/index.ts @@ -1,6 +1,6 @@ import express from 'express' import { graphqlHTTP } from 'express-graphql' -import { buildSchema } from 'graphql' +import { buildSchema, formatError } from 'graphql' import resolver from './resolver' import fs from 'fs' @@ -16,7 +16,11 @@ const schema = buildSchema(fs.readFileSync('./public/v2/graphql.gql').toString() router.use(graphqlHTTP({ schema, rootValue: resolver, - graphiql: true + graphiql: true, + customFormatErrorFn(error) { + console.error(error) + return formatError(error) + } })) export default router