mirror of
https://github.com/retailcrm/graphql-php.git
synced 2025-02-06 07:49:24 +03:00
Fix Bug in PossibleFragmentSpreads validator
ref: graphql/graphql-js@7e147a8dd6
This commit is contained in:
parent
9387548aa1
commit
50cbfb4a44
@ -61,7 +61,13 @@ class PossibleFragmentSpreads extends AbstractValidationRule
|
||||
private function getFragmentType(ValidationContext $context, $name)
|
||||
{
|
||||
$frag = $context->getFragment($name);
|
||||
return $frag ? TypeInfo::typeFromAST($context->getSchema(), $frag->typeCondition) : null;
|
||||
if ($frag) {
|
||||
$type = TypeInfo::typeFromAST($context->getSchema(), $frag->typeCondition);
|
||||
if ($type instanceof CompositeType) {
|
||||
return $type;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private function doTypesOverlap(Schema $schema, CompositeType $fragType, CompositeType $parentType)
|
||||
|
@ -128,6 +128,17 @@ class PossibleFragmentSpreadsTest extends TestCase
|
||||
');
|
||||
}
|
||||
|
||||
/**
|
||||
* @it ignores incorrect type (caught by FragmentsOnCompositeTypes)
|
||||
*/
|
||||
public function testIgnoresIncorrectTypeCaughtByFragmentsOnCompositeTypes()
|
||||
{
|
||||
$this->expectPassesRule(new PossibleFragmentSpreads, '
|
||||
fragment petFragment on Pet { ...badInADifferentWay }
|
||||
fragment badInADifferentWay on String { name }
|
||||
');
|
||||
}
|
||||
|
||||
/**
|
||||
* @it different object into object
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user