OverlappingFieldsCanBeMerged
extends ValidationRule
in package
Table of Contents
- $name : string
- $cachedFieldsAndFragmentNames : SplObjectStorage
- A cache for the "field map" and list of fragment names found in any given selection set. Selection sets may be asked for this information multiple times, so this improves the performance of this validator.
- $comparedFragmentPairs : PairSet
- A memoization for when two fragments are compared "between" each other for conflicts. Two fragments may be compared many times, so memoizing this can dramatically improve the performance of this validator.
- __invoke() : mixed
- fieldsConflictMessage() : mixed
- getName() : mixed
- getSDLVisitor() : array<string|int, mixed>
- Returns structure suitable for GraphQL\Language\Visitor
- getVisitor() : array<string|int, mixed>
- Returns structure suitable for GraphQL\Language\Visitor
- reasonMessage() : mixed
- collectConflictsBetween() : mixed
- Collect all Conflicts between two collections of fields. This is similar to, but different from the `collectConflictsWithin` function above. This check assumes that `collectConflictsWithin` has already been called on each provided collection of fields. This is true because this validator traverses each individual selection set.
- collectConflictsBetweenFieldsAndFragment() : mixed
- Collect all conflicts found between a set of fields and a fragment reference including via spreading in any nested fragments.
- collectConflictsBetweenFragments() : mixed
- Collect all conflicts found between two fragments, including via spreading in any nested fragments.
- collectConflictsWithin() : mixed
- Collect all Conflicts "within" one collection of fields.
- doTypesConflict() : bool
- Two types conflict if both types could not apply to a value simultaneously.
- findConflict() : array<string|int, mixed>|null
- Determines if there is a conflict between two particular fields, including comparing their sub-fields.
- findConflictsBetweenSubSelectionSets() : array<string|int, array<string|int, mixed>>
- Find all conflicts found between two selection sets, including those found via spreading in fragments. Called when determining if conflicts exist between the sub-fields of two overlapping fields.
- findConflictsWithinSelectionSet() : array<string|int, mixed>
- Find all conflicts found "within" a selection set, including those found via spreading in fragments. Called when visiting each SelectionSet in the GraphQL Document.
- getFieldsAndFragmentNames() : array<string|int, mixed>|SplObjectStorage
- Given a selection set, return the collection of fields (a mapping of response name to field ASTs and definitions) as well as a list of fragment names referenced via fragment spreads.
- getReferencedFieldsAndFragmentNames() : array<string|int, mixed>|SplObjectStorage
- Given a reference to a fragment, return the represented collection of fields as well as a list of nested fragment names referenced via fragment spreads.
- internalCollectFieldsAndFragmentNames() : mixed
- Given a reference to a fragment, return the represented collection of fields as well as a list of nested fragment names referenced via fragment spreads.
- sameArguments() : bool
- sameValue() : bool
- subfieldConflicts() : array<string|int, mixed>|null
- Given a series of Conflicts which occurred between two sub-fields, generate a single Conflict.
Properties
$name
protected
string
$name
$cachedFieldsAndFragmentNames
A cache for the "field map" and list of fragment names found in any given selection set. Selection sets may be asked for this information multiple times, so this improves the performance of this validator.
private
SplObjectStorage
$cachedFieldsAndFragmentNames
$comparedFragmentPairs
A memoization for when two fragments are compared "between" each other for conflicts. Two fragments may be compared many times, so memoizing this can dramatically improve the performance of this validator.
private
PairSet
$comparedFragmentPairs
Methods
__invoke()
public
__invoke(ValidationContext $context) : mixed
Parameters
- $context : ValidationContext
Return values
mixed —fieldsConflictMessage()
public
static fieldsConflictMessage(string $responseName, string $reason) : mixed
Parameters
- $responseName : string
- $reason : string
Return values
mixed —getName()
public
getName() : mixed
Return values
mixed —getSDLVisitor()
Returns structure suitable for GraphQL\Language\Visitor
public
getSDLVisitor(SDLValidationContext $context) : array<string|int, mixed>
Parameters
- $context : SDLValidationContext
Tags
Return values
array<string|int, mixed> —getVisitor()
Returns structure suitable for GraphQL\Language\Visitor
public
getVisitor(ValidationContext $context) : array<string|int, mixed>
Parameters
- $context : ValidationContext
Return values
array<string|int, mixed> —reasonMessage()
public
static reasonMessage(mixed $reason) : mixed
Parameters
- $reason : mixed
Return values
mixed —collectConflictsBetween()
Collect all Conflicts between two collections of fields. This is similar to, but different from the `collectConflictsWithin` function above. This check assumes that `collectConflictsWithin` has already been called on each provided collection of fields. This is true because this validator traverses each individual selection set.
private
collectConflictsBetween(ValidationContext $context, array<string|int, array<string|int, mixed>> &$conflicts, bool $parentFieldsAreMutuallyExclusive, array<string|int, mixed> $fieldMap1, array<string|int, mixed> $fieldMap2) : mixed
Parameters
- $context : ValidationContext
- $conflicts : array<string|int, array<string|int, mixed>>
- $parentFieldsAreMutuallyExclusive : bool
- $fieldMap1 : array<string|int, mixed>
- $fieldMap2 : array<string|int, mixed>
Return values
mixed —collectConflictsBetweenFieldsAndFragment()
Collect all conflicts found between a set of fields and a fragment reference including via spreading in any nested fragments.
private
collectConflictsBetweenFieldsAndFragment(ValidationContext $context, array<string|int, array<string|int, mixed>> &$conflicts, array<string|int, bool> &$comparedFragments, bool $areMutuallyExclusive, array<string|int, array<string|int, mixed>> $fieldMap, string $fragmentName) : mixed
Parameters
- $context : ValidationContext
- $conflicts : array<string|int, array<string|int, mixed>>
- $comparedFragments : array<string|int, bool>
- $areMutuallyExclusive : bool
- $fieldMap : array<string|int, array<string|int, mixed>>
- $fragmentName : string
Return values
mixed —collectConflictsBetweenFragments()
Collect all conflicts found between two fragments, including via spreading in any nested fragments.
private
collectConflictsBetweenFragments(ValidationContext $context, array<string|int, array<string|int, mixed>> &$conflicts, bool $areMutuallyExclusive, string $fragmentName1, string $fragmentName2) : mixed
Parameters
- $context : ValidationContext
- $conflicts : array<string|int, array<string|int, mixed>>
- $areMutuallyExclusive : bool
- $fragmentName1 : string
- $fragmentName2 : string
Return values
mixed —collectConflictsWithin()
Collect all Conflicts "within" one collection of fields.
private
collectConflictsWithin(ValidationContext $context, array<string|int, array<string|int, mixed>> &$conflicts, array<string|int, array<string|int, mixed>> $fieldMap) : mixed
Parameters
- $context : ValidationContext
- $conflicts : array<string|int, array<string|int, mixed>>
- $fieldMap : array<string|int, array<string|int, mixed>>
Return values
mixed —doTypesConflict()
Two types conflict if both types could not apply to a value simultaneously.
private
doTypesConflict(Type $type1, Type $type2) : bool
Composite types are ignored as their individual field types will be compared later recursively. However List and Non-Null types must match.
Parameters
Return values
bool —findConflict()
Determines if there is a conflict between two particular fields, including comparing their sub-fields.
private
findConflict(ValidationContext $context, bool $parentFieldsAreMutuallyExclusive, string $responseName, array<string|int, mixed> $field1, array<string|int, mixed> $field2) : array<string|int, mixed>|null
Parameters
- $context : ValidationContext
- $parentFieldsAreMutuallyExclusive : bool
- $responseName : string
- $field1 : array<string|int, mixed>
- $field2 : array<string|int, mixed>
Return values
array<string|int, mixed>|null —findConflictsBetweenSubSelectionSets()
Find all conflicts found between two selection sets, including those found via spreading in fragments. Called when determining if conflicts exist between the sub-fields of two overlapping fields.
private
findConflictsBetweenSubSelectionSets(ValidationContext $context, bool $areMutuallyExclusive, CompositeType $parentType1, SelectionSetNode $selectionSet1, CompositeType $parentType2, SelectionSetNode $selectionSet2) : array<string|int, array<string|int, mixed>>
Parameters
- $context : ValidationContext
- $areMutuallyExclusive : bool
- $parentType1 : CompositeType
- $selectionSet1 : SelectionSetNode
- $parentType2 : CompositeType
- $selectionSet2 : SelectionSetNode
Return values
array<string|int, array<string|int, mixed>> —findConflictsWithinSelectionSet()
Find all conflicts found "within" a selection set, including those found via spreading in fragments. Called when visiting each SelectionSet in the GraphQL Document.
private
findConflictsWithinSelectionSet(ValidationContext $context, CompositeType $parentType, SelectionSetNode $selectionSet) : array<string|int, mixed>
Parameters
- $context : ValidationContext
- $parentType : CompositeType
- $selectionSet : SelectionSetNode
Return values
array<string|int, mixed> —getFieldsAndFragmentNames()
Given a selection set, return the collection of fields (a mapping of response name to field ASTs and definitions) as well as a list of fragment names referenced via fragment spreads.
private
getFieldsAndFragmentNames(ValidationContext $context, CompositeType $parentType, SelectionSetNode $selectionSet) : array<string|int, mixed>|SplObjectStorage
Parameters
- $context : ValidationContext
- $parentType : CompositeType
- $selectionSet : SelectionSetNode
Return values
array<string|int, mixed>|SplObjectStorage —getReferencedFieldsAndFragmentNames()
Given a reference to a fragment, return the represented collection of fields as well as a list of nested fragment names referenced via fragment spreads.
private
getReferencedFieldsAndFragmentNames(ValidationContext $context, FragmentDefinitionNode $fragment) : array<string|int, mixed>|SplObjectStorage
Parameters
- $context : ValidationContext
- $fragment : FragmentDefinitionNode
Return values
array<string|int, mixed>|SplObjectStorage —internalCollectFieldsAndFragmentNames()
Given a reference to a fragment, return the represented collection of fields as well as a list of nested fragment names referenced via fragment spreads.
private
internalCollectFieldsAndFragmentNames(ValidationContext $context, CompositeType $parentType, SelectionSetNode $selectionSet, array<string|int, array<string|int, array<string|int, mixed>>> &$astAndDefs, array<string|int, bool> &$fragmentNames) : mixed
Parameters
- $context : ValidationContext
- $parentType : CompositeType
- $selectionSet : SelectionSetNode
- $astAndDefs : array<string|int, array<string|int, array<string|int, mixed>>>
- $fragmentNames : array<string|int, bool>
Return values
mixed —sameArguments()
private
sameArguments(array<string|int, ArgumentNode> $arguments1, array<string|int, ArgumentNode> $arguments2) : bool
Parameters
- $arguments1 : array<string|int, ArgumentNode>
- $arguments2 : array<string|int, ArgumentNode>
Return values
bool —sameValue()
private
sameValue(Node $value1, Node $value2) : bool
Parameters
Return values
bool —subfieldConflicts()
Given a series of Conflicts which occurred between two sub-fields, generate a single Conflict.
private
subfieldConflicts(array<string|int, array<string|int, mixed>> $conflicts, string $responseName, FieldNode $ast1, FieldNode $ast2) : array<string|int, mixed>|null
Parameters
- $conflicts : array<string|int, array<string|int, mixed>>
- $responseName : string
- $ast1 : FieldNode
- $ast2 : FieldNode