Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -168,12 +168,6 @@ parameters:
count: 1
path: src/Factory/Type/PartialInputTypeFactory.php

-
message: '#^Property GraphQL\\Type\\Definition\\InputObjectType\:\:\$config \(array\{name\?\: string\|null, description\?\: string\|null, isOneOf\?\: bool\|null, fields\: \(callable\(\)\: iterable\<array\{name\?\: string, type\: callable\(\)\: \(GraphQL\\Type\\Definition\\InputType&GraphQL\\Type\\Definition\\Type\)\|\(GraphQL\\Type\\Definition\\InputType&GraphQL\\Type\\Definition\\Type\), defaultValue\?\: mixed, description\?\: string\|null, deprecationReason\?\: string\|null, astNode\?\: GraphQL\\Language\\AST\\InputValueDefinitionNode\|null\}\|callable\(\)\: \(array\{name\?\: string, type\: callable\(\)\: \(GraphQL\\Type\\Definition\\InputType&GraphQL\\Type\\Definition\\Type\)\|\(GraphQL\\Type\\Definition\\InputType&GraphQL\\Type\\Definition\\Type\), defaultValue\?\: mixed, description\?\: string\|null, deprecationReason\?\: string\|null, astNode\?\: GraphQL\\Language\\AST\\InputValueDefinitionNode\|null\}\|GraphQL\\Type\\Definition\\InputObjectField\|\(GraphQL\\Type\\Definition\\InputType&GraphQL\\Type\\Definition\\Type\)\)\|GraphQL\\Type\\Definition\\InputObjectField\|\(GraphQL\\Type\\Definition\\InputType&GraphQL\\Type\\Definition\\Type\)\>\)\|iterable\<array\{name\?\: string, type\: \(callable\(\)\: \(GraphQL\\Type\\Definition\\InputType&GraphQL\\Type\\Definition\\Type\)\)\|\(GraphQL\\Type\\Definition\\InputType&GraphQL\\Type\\Definition\\Type\), defaultValue\?\: mixed, description\?\: string\|null, deprecationReason\?\: string\|null, astNode\?\: GraphQL\\Language\\AST\\InputValueDefinitionNode\|null\}\|\(callable\(\)\: \(array\{name\?\: string, type\: callable\(\)\: \(GraphQL\\Type\\Definition\\InputType&GraphQL\\Type\\Definition\\Type\)\|\(GraphQL\\Type\\Definition\\InputType&GraphQL\\Type\\Definition\\Type\), defaultValue\?\: mixed, description\?\: string\|null, deprecationReason\?\: string\|null, astNode\?\: GraphQL\\Language\\AST\\InputValueDefinitionNode\|null\}\|GraphQL\\Type\\Definition\\InputObjectField\|\(GraphQL\\Type\\Definition\\InputType&GraphQL\\Type\\Definition\\Type\)\)\)\|GraphQL\\Type\\Definition\\InputObjectField\|\(GraphQL\\Type\\Definition\\InputType&GraphQL\\Type\\Definition\\Type\)\>, parseValue\?\: \(callable\(array\<string, mixed\>\)\: mixed\)\|null, astNode\?\: GraphQL\\Language\\AST\\InputObjectTypeDefinitionNode\|null, extensionASTNodes\?\: array\<GraphQL\\Language\\AST\\InputObjectTypeExtensionNode\>\|null\}\) does not accept array\{name\?\: string\|null, description\?\: string\|null, isOneOf\?\: bool\|null, fields\: Closure\(\)\: list, parseValue\?\: \(callable\(array\<string, mixed\>\)\: mixed\)\|null, astNode\?\: GraphQL\\Language\\AST\\InputObjectTypeDefinitionNode\|null, extensionASTNodes\?\: array\<GraphQL\\Language\\AST\\InputObjectTypeExtensionNode\>\|null\}\.$#'
identifier: assign.propertyType
count: 1
path: src/Factory/Type/PartialInputTypeFactory.php

-
message: '#^Parameter \#1 \$property of method GraphQL\\Doctrine\\Factory\\AbstractFactory\:\:isPropertyExcluded\(\) expects ReflectionProperty, ReflectionProperty\|null given\.$#'
identifier: argument.type
Expand Down
10 changes: 5 additions & 5 deletions src/Factory/Type/PartialInputTypeFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ final class PartialInputTypeFactory extends AbstractTypeFactory
*/
public function create(string $className, string $typeName): InputObjectType
{
$type = clone $this->types->getInput($className);
$fieldsGetter = $type->config['fields'];
$config = $this->types->getInput($className)->config;
$fieldsGetter = $config['fields'];

$optionalFieldsGetter = function () use ($fieldsGetter): array {
$optionalFields = [];
Expand All @@ -40,9 +40,9 @@ public function create(string $className, string $typeName): InputObjectType

return $optionalFields;
};
$type->config['fields'] = $optionalFieldsGetter;
$type->name = $typeName;
$config['name'] = $typeName;
$config['fields'] = $optionalFieldsGetter;

return $type;
return new InputObjectType($config);
}
}
24 changes: 24 additions & 0 deletions tests/InputTypesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,30 @@ public function testDefaultValuesPartialInput(): void
$this->assertType('tests/data/DefaultValuePartialInput.graphqls', $actual);
}

public function testPartialInputIsPartialWhenInputFieldsAreAlreadyResolved(): void
{
$input = $this->types->getInput(Blog\Model\Special\DefaultValue::class);
$input->getFields();

$partialInput = $this->types->getPartialInput(Blog\Model\Special\DefaultValue::class);
$this->assertType('tests/data/DefaultValuePartialInput.graphqls', $partialInput);
}

public function testInputIsNotPartialWhenPartialInputFieldsAreAlreadyResolved(): void
{
$partialInput = $this->types->getPartialInput(Blog\Model\Special\DefaultValue::class);
$partialInput->getFields();

$input = $this->types->getInput(Blog\Model\Special\DefaultValue::class);
$this->assertType('tests/data/DefaultValueInput.graphqls', $input);
}

public function testPartialInputHasSameDescriptionAsInput(): void
{
$partialInput = $this->types->getPartialInput(Post::class);
self::assertSame('A blog post with title and body.', $partialInput->description);
}

public function testSelfSupportInput(): void
{
$actual = $this->types->getInput(Blog\Model\Special\SelfSupport::class);
Expand Down