Skip to content

Commit

Permalink
Add logging for graphql errors (#242)
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasecdb committed Dec 28, 2021
1 parent a82de48 commit 3a1481d
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/middlewares/graphql.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { Request } from 'express'
import { graphqlHTTP } from 'express-graphql'
import { formatError } from 'graphql'

import config from '../config'
import { createLoaders } from '../loaders/createLoaders'
Expand All @@ -13,6 +14,11 @@ export function graphql() {
return {
schema,
graphiql: config.NODE_ENV !== 'production',
customFormatErrorFn: (error) => {
console.error(error)

return formatError(error)
},
context: {
...createLoaders(user),
user,
Expand Down

0 comments on commit 3a1481d

Please sign in to comment.