Skip to content

Commit 4c27e1d

Browse files
authored
Merge pull request #16 from moufmouf/fix_13
GraphQL type is nullable is query parameter has default value
2 parents aa5d8f5 + dcd0479 commit 4c27e1d

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

src/ControllerQueryProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ private function mapParameters(ReflectionMethod $refMethod, \ReflectionMethod $s
195195

196196
try {
197197
$arr = [
198-
'type' => $this->mapType($phpdocType, $parameter->getDocBlockTypes(), $allowsNull, true),
198+
'type' => $this->mapType($phpdocType, $parameter->getDocBlockTypes(), $allowsNull || $parameter->isDefaultValueAvailable(), true),
199199
];
200200
} catch (TypeMappingException $e) {
201201
throw TypeMappingException::wrapWithParamInfo($e, $parameter);

tests/ControllerQueryProviderTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ public function testQueryProvider()
4949
$this->assertInstanceOf(FloatType::class, $usersQuery->getArgument('float')->getType());
5050
$this->assertInstanceOf(DateTimeType::class, $usersQuery->getArgument('dateTimeImmutable')->getType());
5151
$this->assertInstanceOf(DateTimeType::class, $usersQuery->getArgument('dateTime')->getType());
52+
$this->assertInstanceOf(StringType::class, $usersQuery->getArgument('withDefault')->getType());
5253
$this->assertSame('TestObject', $usersQuery->getArgument('list')->getType()->getTypeOf()->getItemType()->getTypeOf()->getName());
5354

5455
$mockResolveInfo = $this->createMock(ResolveInfo::class);

0 commit comments

Comments
 (0)