mirror of
https://github.com/retailcrm/graphql-php.git
synced 2024-11-22 21:06:05 +03:00
testDetectsNonNullFieldAddedToInputType
This commit is contained in:
parent
cf4cccf4d6
commit
dde2747918
@ -324,7 +324,7 @@ class FindBreakingChanges
|
|||||||
foreach ($newTypeFieldsDef as $fieldName => $fieldDef) {
|
foreach ($newTypeFieldsDef as $fieldName => $fieldDef) {
|
||||||
if (!isset($oldTypeFieldsDef[$fieldName]) && $fieldDef->getType() instanceof NonNull) {
|
if (!isset($oldTypeFieldsDef[$fieldName]) && $fieldDef->getType() instanceof NonNull) {
|
||||||
$newTypeName = $newType->name;
|
$newTypeName = $newType->name;
|
||||||
$breakingFieldChanges[] = ['type' => self::BREAKING_CHANGE_NON_NULL_INPUT_FIELD_ADDED, 'description' => "A non-null field ${fieldName} on input type ${$newTypeName} was added"];
|
$breakingFieldChanges[] = ['type' => self::BREAKING_CHANGE_NON_NULL_INPUT_FIELD_ADDED, 'description' => "A non-null field ${fieldName} on input type ${newTypeName} was added."];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -428,4 +428,49 @@ class FindBreakingChangesTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
$this->assertEquals($expectedFieldChanges, FindBreakingChanges::findFieldsThatChangedType($oldSchema, $newSchema));
|
$this->assertEquals($expectedFieldChanges, FindBreakingChanges::findFieldsThatChangedType($oldSchema, $newSchema));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testDetectsNonNullFieldAddedToInputType()
|
||||||
|
{
|
||||||
|
$oldInputType = new InputObjectType([
|
||||||
|
'name' => 'InputType1',
|
||||||
|
'fields' => [
|
||||||
|
'field1' => Type::string()
|
||||||
|
]
|
||||||
|
]);
|
||||||
|
|
||||||
|
$newInputType = new InputObjectType([
|
||||||
|
'name' => 'InputType1',
|
||||||
|
'fields' => [
|
||||||
|
'field1' => Type::string(),
|
||||||
|
'requiredField' => Type::nonNull(Type::int()),
|
||||||
|
'optionalField' => Type::boolean()
|
||||||
|
]
|
||||||
|
]);
|
||||||
|
|
||||||
|
$oldSchema = new Schema([
|
||||||
|
'query' => new ObjectType([
|
||||||
|
'name' => 'root',
|
||||||
|
'fields' => [
|
||||||
|
'type1' => $oldInputType
|
||||||
|
]
|
||||||
|
])
|
||||||
|
]);
|
||||||
|
|
||||||
|
$newSchema = new Schema([
|
||||||
|
'query' => new ObjectType([
|
||||||
|
'name' => 'root',
|
||||||
|
'fields' => [
|
||||||
|
'type1' => $newInputType
|
||||||
|
]
|
||||||
|
])
|
||||||
|
]);
|
||||||
|
|
||||||
|
$this->assertEquals(
|
||||||
|
[
|
||||||
|
'type' => FindBreakingChanges::BREAKING_CHANGE_NON_NULL_INPUT_FIELD_ADDED,
|
||||||
|
'description' => 'A non-null field requiredField on input type InputType1 was added.'
|
||||||
|
],
|
||||||
|
FindBreakingChanges::findFieldsThatChangedType($oldSchema, $newSchema)[0]
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user