chore: Refactor exposing graphQL errors
This commit is contained in:
@@ -1,15 +1,18 @@
|
|||||||
import { graphqlHTTP } from 'express-graphql';
|
import { graphqlHTTP } from 'express-graphql';
|
||||||
import graphQLSchema from '../graphql/graphql-schema'
|
import graphQLSchema from '../graphql/graphql-schema'
|
||||||
|
import logger from '../helpers/logger';
|
||||||
|
|
||||||
const graphQLInstance = graphqlHTTP({
|
const graphQLInstance = graphqlHTTP({
|
||||||
schema: graphQLSchema,
|
schema: graphQLSchema,
|
||||||
graphiql: true,
|
graphiql: true,
|
||||||
customFormatErrorFn: (error) => ({
|
customFormatErrorFn: (error) => {
|
||||||
message: error.message,
|
logger.error(error.path + ' : ' + error.message + '\n' + error.stack)
|
||||||
locations: error.locations,
|
|
||||||
stack: error.stack ? error.stack.split('\n') : [],
|
return {
|
||||||
path: error.path,
|
message: error.message,
|
||||||
})
|
locations: error.locations
|
||||||
|
}
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
export default graphQLInstance;
|
export default graphQLInstance;
|
||||||
|
Reference in New Issue
Block a user