public function __invoke(ValidationContext $context) { $comparedSet = new PairSet(); return [Node::SELECTION_SET => ['leave' => function (SelectionSet $selectionSet) use($context, $comparedSet) { $fieldMap = $this->collectFieldASTsAndDefs($context, $context->getType(), $selectionSet); $conflicts = $this->findConflicts($fieldMap, $context, $comparedSet); if (!empty($conflicts)) { return array_map(function ($conflict) { $responseName = $conflict[0][0]; $reason = $conflict[0][1]; $blameNodes = $conflict[1]; return new Error(Messages::fieldsConflictMessage($responseName, $reason), $blameNodes); }, $conflicts); } }]]; }
public function testConflictingScalarReturnTypes() { $this->expectFailsRuleWithSchema($this->getTestSchema(), new OverlappingFieldsCanBeMerged(), ' { boxUnion { ...on IntBox { scalar } ...on StringBox { scalar } } } ', [new FormattedError(Messages::fieldsConflictMessage('scalar', 'they return differing types Int and String'), [new SourceLocation(5, 15), new SourceLocation(8, 15)])]); }