Hide errors stacktrace
eaceto opened this issue · 0 comments
eaceto commented
Is your feature request related to a problem? Please describe.
When a GraphQL error appears a complete description of the error is sent, which include stack trace information in most cases.
Describe the solution you'd like
Example error
{
"errors":[
{
"message":"Variable \"$person\" got invalid value \"lukesk\"; Value \"lukesk\" does not exist in \"StarWarsPeople\" enum.",
"extensions":{
"code":"BAD_USER_INPUT",
"exception":{
"stacktrace":[
"GraphQLError: Variable \"$person\" got invalid value \"lukesk\"; Value \"lukesk\" does not exist in \"StarWarsPeople\" enum.",
" at /usr/src/app/node_modules/graphql/execution/values.js:116:15",
" at coerceInputValueImpl (/usr/src/app/node_modules/graphql/utilities/coerceInputValue.js:131:9)",
" at coerceInputValueImpl (/usr/src/app/node_modules/graphql/utilities/coerceInputValue.js:54:14)",
" at coerceInputValue (/usr/src/app/node_modules/graphql/utilities/coerceInputValue.js:37:10)",
" at _loop (/usr/src/app/node_modules/graphql/execution/values.js:109:69)",
" at coerceVariableValues (/usr/src/app/node_modules/graphql/execution/values.js:121:16)",
" at getVariableValues (/usr/src/app/node_modules/graphql/execution/values.js:50:19)",
" at buildExecutionContext (/usr/src/app/node_modules/graphql/execution/execute.js:203:61)",
" at executeImpl (/usr/src/app/node_modules/graphql/execution/execute.js:101:20)",
" at execute (/usr/src/app/node_modules/graphql/execution/execute.js:60:35)"
]
}
}
}
]
}
We should give the possibility to hide (stop propagating) errors[].extensions.exception , for example, by setting the following properties in the configuration yaml:
routes:
- http:
uri: '/films/{film}'
method: GET
graphql:
endpoint: 'https://swapi.skyra.pw/'
query: |
{
getFilm(film: $film) {
title
releaseDate
producers
episodeId
}
}
types:
film: Float
errors:
hidePath: true # defaults to false
hideLocations: true # defaults to false
extensions:
hide: true # defaults to false. True hides the complete **extensions** dictionary
codeMapping:
BAD_USER_INPUT: 400 # Maps **extensions.code** to HTTP Status. Error "BAD_USER_INPUT" maps to Status Code 400 (Bad Request)