File tree Expand file tree Collapse file tree 2 files changed +8
-8
lines changed
src/GraphQl/Type/Definition
tests/GraphQl/Type/Definition Expand file tree Collapse file tree 2 files changed +8
-8
lines changed Original file line number Diff line number Diff line change 14
14
namespace ApiPlatform \Core \GraphQl \Type \Definition ;
15
15
16
16
use GraphQL \Error \Error ;
17
- use GraphQL \Error \InvariantViolation ;
18
17
use GraphQL \Language \AST \BooleanValueNode ;
19
18
use GraphQL \Language \AST \FloatValueNode ;
20
19
use GraphQL \Language \AST \IntValueNode ;
@@ -44,7 +43,7 @@ public function serialize($value)
44
43
{
45
44
// is_iterable
46
45
if (!(\is_array ($ value ) || $ value instanceof \Traversable)) {
47
- throw new InvariantViolation (sprintf ('Iterable cannot represent non iterable value: %s ' , Utils::printSafe ($ value )));
46
+ throw new Error (sprintf ('Iterable cannot represent non iterable value: %s ' , Utils::printSafe ($ value )));
48
47
}
49
48
50
49
return $ value ;
@@ -66,13 +65,14 @@ public function parseValue($value)
66
65
/**
67
66
* {@inheritdoc}
68
67
*/
69
- public function parseLiteral ($ valueNode )
68
+ public function parseLiteral ($ valueNode, array $ variables = null )
70
69
{
71
70
if ($ valueNode instanceof ObjectValueNode || $ valueNode instanceof ListValueNode) {
72
71
return $ this ->parseIterableLiteral ($ valueNode );
73
72
}
74
73
75
- return null ;
74
+ // Intentionally without message, as all information already in wrapped Exception
75
+ throw new \Exception ();
76
76
}
77
77
78
78
/**
Original file line number Diff line number Diff line change 15
15
16
16
use ApiPlatform \Core \GraphQl \Type \Definition \IterableType ;
17
17
use GraphQL \Error \Error ;
18
- use GraphQL \Error \InvariantViolation ;
19
18
use GraphQL \Language \AST \BooleanValueNode ;
20
19
use GraphQL \Language \AST \FloatValueNode ;
21
20
use GraphQL \Language \AST \IntValueNode ;
@@ -36,8 +35,8 @@ public function testSerialize()
36
35
{
37
36
$ iterableType = new IterableType ();
38
37
39
- $ this ->expectException (InvariantViolation ::class);
40
- $ this ->expectExceptionMessage ('Iterable cannot represent non iterable value: " foo" ' );
38
+ $ this ->expectException (Error ::class);
39
+ $ this ->expectExceptionMessage ('Iterable cannot represent non iterable value: foo ' );
41
40
42
41
$ iterableType ->serialize ('foo ' );
43
42
@@ -60,7 +59,8 @@ public function testParseLiteral()
60
59
{
61
60
$ iterableType = new IterableType ();
62
61
63
- $ this ->assertNull ($ iterableType ->parseLiteral (new IntValueNode (['value ' => 1 ])));
62
+ $ this ->expectException (\Exception::class);
63
+ $ iterableType ->parseLiteral (new IntValueNode (['value ' => 1 ]));
64
64
65
65
$ listValueNode = new ListValueNode (['values ' => []]);
66
66
$ this ->assertEquals ([], $ iterableType ->parseLiteral ($ listValueNode ));
You can’t perform that action at this time.
0 commit comments