mirror of
https://github.com/retailcrm/graphql-php.git
synced 2024-11-22 04:46:04 +03:00
testDetectsRemovalOfFieldArgument
This commit is contained in:
parent
cac011246e
commit
fc9c5e85aa
@ -164,9 +164,10 @@ class FindBreakingChanges
|
||||
}
|
||||
);
|
||||
if (!$newArgDef) {
|
||||
$argName = $oldArgDef->name;
|
||||
$breakingChanges[] = [
|
||||
'type' => self::BREAKING_CHANGE_ARG_REMOVED,
|
||||
'description' => "${$oldTypeName}->${$fieldName} arg ${oldArgName} was removed"
|
||||
'description' => "${oldTypeName}->${fieldName} arg ${argName} was removed"
|
||||
];
|
||||
} else {
|
||||
$isSafe = self::isChangeSafeForInputObjectFieldOrFieldArg($oldArgDef->getType(), $newArgDef->getType());
|
||||
|
@ -592,4 +592,97 @@ class FindBreakingChangesTest extends \PHPUnit_Framework_TestCase
|
||||
FindBreakingChanges::findValuesRemovedFromEnums($oldSchema, $newSchema)[0]
|
||||
);
|
||||
}
|
||||
|
||||
public function testDetectsRemovalOfFieldArgument()
|
||||
{
|
||||
|
||||
$oldType = new ObjectType([
|
||||
'name' => 'Type1',
|
||||
'fields' => [
|
||||
'field1' => [
|
||||
'type' => Type::string(),
|
||||
'args' => [
|
||||
'name' => Type::string()
|
||||
]
|
||||
]
|
||||
]
|
||||
]);
|
||||
|
||||
|
||||
$inputType = new InputObjectType([
|
||||
'name' => 'InputType1',
|
||||
'fields' => [
|
||||
'field1' => Type::string()
|
||||
]
|
||||
]);
|
||||
|
||||
$oldInterfaceType = new InterfaceType([
|
||||
'name' => 'Interface1',
|
||||
'fields' => [
|
||||
'field1' => [
|
||||
'type' => Type::string(),
|
||||
'args' => [
|
||||
'arg1' => Type::boolean(),
|
||||
'objectArg' => $inputType
|
||||
]
|
||||
]
|
||||
]
|
||||
]);
|
||||
|
||||
$newType = new ObjectType([
|
||||
'name' => 'Type1',
|
||||
'fields' => [
|
||||
'field1' => [
|
||||
'type' => Type::string(),
|
||||
'args' => []
|
||||
]
|
||||
]
|
||||
]);
|
||||
|
||||
$newInterfaceType = new InterfaceType([
|
||||
'name' => 'Interface1',
|
||||
'fields' => [
|
||||
'field1' => Type::string()
|
||||
]
|
||||
]);
|
||||
|
||||
$oldSchema = new Schema([
|
||||
'query' => new ObjectType([
|
||||
'name' => 'root',
|
||||
'fields' => [
|
||||
'type1' => $oldType,
|
||||
'type2' => $oldInterfaceType
|
||||
],
|
||||
'types' => [$oldType, $oldInterfaceType]
|
||||
])
|
||||
]);
|
||||
|
||||
$newSchema = new Schema([
|
||||
'query' => new ObjectType([
|
||||
'name' => 'root',
|
||||
'fields' => [
|
||||
'type1' => $newType,
|
||||
'type2' => $newInterfaceType
|
||||
],
|
||||
'types' => [$newType, $newInterfaceType]
|
||||
])
|
||||
]);
|
||||
|
||||
$expectedChanges = [
|
||||
[
|
||||
'type' => FindBreakingChanges::BREAKING_CHANGE_ARG_REMOVED,
|
||||
'description' => 'Type1->field1 arg name was removed',
|
||||
],
|
||||
[
|
||||
'type' => FindBreakingChanges::BREAKING_CHANGE_ARG_REMOVED,
|
||||
'description' => 'Interface1->field1 arg arg1 was removed',
|
||||
],
|
||||
[
|
||||
'type' => FindBreakingChanges::BREAKING_CHANGE_ARG_REMOVED,
|
||||
'description' => 'Interface1->field1 arg objectArg was removed',
|
||||
]
|
||||
];
|
||||
|
||||
$this->assertEquals($expectedChanges, FindBreakingChanges::findArgChanges($oldSchema, $newSchema)['breakingChanges']);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user