1
0
mirror of https://github.com/tcgdex/cards-database.git synced 2025-04-22 19:02:10 +00:00

refactor: Add more logging forGraphQL errors (#218)

This commit is contained in:
Florian Bouillon 2021-12-31 00:11:53 +01:00 committed by GitHub
parent 9956808686
commit 16467d4a19
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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