Skip to content

Commit 77a4a2f

Browse files
committed
throw raw exception in debug mode
1 parent eb3988f commit 77a4a2f

File tree

3 files changed

+23
-8
lines changed

3 files changed

+23
-8
lines changed

Relay/Connection/Output/ConnectionBuilder.php

+6-6
Original file line numberDiff line numberDiff line change
@@ -101,12 +101,12 @@ public static function connectionFromArraySlice($arraySlice, array $args, array
101101

102102
$edges = [];
103103

104-
var_dump(compact(
105-
'countArraySlice', 'slice', 'end', 'length',
106-
'offset', 'first', 'after', 'before',
107-
'beforeOffset', 'afterOffset',
108-
'startOffset', 'endOffset', 'sliceStart'
109-
));
104+
// var_dump(compact(
105+
// 'countArraySlice', 'slice', 'end', 'length',
106+
// 'offset', 'first', 'after', 'before',
107+
// 'beforeOffset', 'afterOffset',
108+
// 'startOffset', 'endOffset', 'sliceStart'
109+
// ));
110110

111111
foreach($slice as $index => $value) {
112112
$edges[] = new Edge(static::offsetToCursor($startOffset + $index), $value);

Request/Executor.php

+16-2
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,13 @@ class Executor
1919
*/
2020
private $dispatcher;
2121

22-
public function __construct(Schema $schema, EventDispatcherInterface $dispatcher)
22+
private $enabledDebug;
23+
24+
public function __construct(Schema $schema, EventDispatcherInterface $dispatcher, $enabledDebug)
2325
{
2426
$this->schema = $schema;
2527
$this->dispatcher = $dispatcher;
28+
$this->enabledDebug = $enabledDebug;
2629
}
2730

2831
public function execute(array $data, array $context = [])
@@ -33,12 +36,23 @@ public function execute(array $data, array $context = [])
3336
$event = new ExecutorContextEvent($context);
3437
$this->dispatcher->dispatch(Events::EXECUTOR_CONTEXT, $event);
3538

36-
return GraphQLExecutor::execute(
39+
$executionResult = GraphQLExecutor::execute(
3740
$this->schema,
3841
$ast,
3942
$event->getExecutorContext(),
4043
$data['variables'],
4144
$data['operationName']
4245
);
46+
47+
if ($this->enabledDebug && !empty($executionResult->errors)) {
48+
foreach($executionResult->errors as $error) {
49+
// if is a try catch exception wrapped in Error
50+
if ($error->getPrevious() instanceof \Exception) {
51+
throw $executionResult->errors[0]->getPrevious();
52+
}
53+
}
54+
}
55+
56+
return $executionResult;
4357
}
4458
}

Resources/config/services.yml

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ services:
44
arguments:
55
- "@overblog_graph.schema"
66
- "@event_dispatcher"
7+
- %kernel.debug%
78

89
overblog_graph.request_parser:
910
class: Overblog\GraphBundle\Request\Parser

0 commit comments

Comments
 (0)