File tree Expand file tree Collapse file tree 2 files changed +38
-0
lines changed
Fixtures/Integration/Controllers Expand file tree Collapse file tree 2 files changed +38
-0
lines changed Original file line number Diff line number Diff line change 55
66
77use Porpaginas \Arrays \ArrayResult ;
8+ use Porpaginas \Result ;
89use TheCodingMachine \GraphQLite \Annotations \Mutation ;
910use TheCodingMachine \GraphQLite \Annotations \Query ;
1011use TheCodingMachine \GraphQLite \Annotations \Security ;
@@ -78,4 +79,15 @@ public function getOtherContact(): Contact
7879 {
7980 return new Contact ('Joe ' );
8081 }
82+
83+ /**
84+ * Test that we can have nullable results from Porpaginas.
85+ *
86+ * @Query()
87+ * @return Result|Contact[]|null
88+ */
89+ public function getNullableResult (): ?Result
90+ {
91+ return null ;
92+ }
8193}
Original file line number Diff line number Diff line change @@ -1545,4 +1545,30 @@ public function testInputOutputNameConflict(): void
15451545
15461546 $ schema ->validate ();
15471547 }
1548+
1549+ public function testNullableResult (){
1550+ /**
1551+ * @var Schema $schema
1552+ */
1553+ $ schema = $ this ->mainContainer ->get (Schema::class);
1554+
1555+ $ queryString = '
1556+ query {
1557+ nullableResult {
1558+ count
1559+ }
1560+ }
1561+ ' ;
1562+
1563+ $ result = GraphQL::executeQuery (
1564+ $ schema ,
1565+ $ queryString
1566+ );
1567+ $ resultArray = $ result ->toArray (Debug::RETHROW_UNSAFE_EXCEPTIONS );
1568+ if (isset ($ resultArray ['errors ' ]) || !isset ($ resultArray ['data ' ])) {
1569+ $ this ->fail ('Expected a successful answer. Got ' .json_encode ($ resultArray , JSON_PRETTY_PRINT ));
1570+ }
1571+ $ this ->assertNull ($ resultArray ['data ' ]['getNullableResult ' ]);
1572+ }
1573+
15481574}
You can’t perform that action at this time.
0 commit comments