In general it’s a copy from this question.
I am using laravel lighthouse framework for graphQl api, and I am trying to return error for client, for example:
public function doSomething($_, array $args, GraphQLContext $context, ResolveInfo $resolveInfo){
$apples_count = $context->user()->apples;
if(apples_count > 10){
//do something
return [
'success' => true
];
}else{
throw new Error('You must have more then 10 apples');
}
}
If user will have less then 10 apples, this will be returned:
{
"errors": [
{
"message": "You must have more then 10 apples",
"locations": [
{
"line": 2,
"column": 3
}
],
"path": [
"doSomething"
]
}
],
"data": {
"doSomething": null
}
}
Question: How to remove “locations” and “path” from response? (I want to have there just “errors” with “message” and “data”)
What I tried:
- Created my own exception, but this allow only to add data in response (the same written in comment from question that I linked above)
- Changed APP_DEBUG=false and APP_ENV=production
- Added LIGHTHOUSE_DEBUG=null|false|0
Nothing helped! Can you help me to do what I want?