QueryComplexity
extends QuerySecurityRule
in package
Table of Contents
- DISABLED = 0
- $name : string
- $complexity : int
- $context : ValidationContext
- $fieldNodeAndDefs : ArrayObject
- $fragments : array<string|int, FragmentDefinitionNode>
- $maxQueryComplexity : int
- $rawVariableValues : array<string|int, mixed>|null
- $variableDefs : ArrayObject
- __construct() : mixed
- __invoke() : mixed
- getMaxQueryComplexity() : mixed
- getName() : mixed
- getQueryComplexity() : mixed
- getRawVariableValues() : mixed
- getSDLVisitor() : array<string|int, mixed>
- Returns structure suitable for GraphQL\Language\Visitor
- getVisitor() : mixed
- maxQueryComplexityErrorMessage() : mixed
- setMaxQueryComplexity() : mixed
- Set max query complexity. If equal to 0 no check is done. Must be greater or equal to 0.
- setRawVariableValues() : mixed
- checkIfGreaterOrEqualToZero() : mixed
- check if equal to 0 no check is done. Must be greater or equal to 0.
- collectFieldASTsAndDefs() : ArrayObject
- Given a selectionSet, adds all of the fields in that selection to the passed in map of fields, and returns it at the end.
- gatherFragmentDefinition() : mixed
- getFieldName() : mixed
- getFragment() : mixed
- getFragments() : array<string|int, FragmentDefinitionNode>
- invokeIfNeeded() : array<string|int, callable>
- isEnabled() : mixed
- astFieldInfo() : mixed
- buildFieldArguments() : mixed
- directiveExcludesField() : mixed
- fieldComplexity() : mixed
- nodeComplexity() : mixed
Constants
DISABLED
public
mixed
DISABLED
= 0
Properties
$name
protected
string
$name
$complexity
private
int
$complexity
$context
private
ValidationContext
$context
$fieldNodeAndDefs
private
ArrayObject
$fieldNodeAndDefs
$fragments
private
array<string|int, FragmentDefinitionNode>
$fragments
= []
$maxQueryComplexity
private
int
$maxQueryComplexity
$rawVariableValues
private
array<string|int, mixed>|null
$rawVariableValues
= []
$variableDefs
private
ArrayObject
$variableDefs
Methods
__construct()
public
__construct(mixed $maxQueryComplexity) : mixed
Parameters
- $maxQueryComplexity : mixed
Return values
mixed —__invoke()
public
__invoke(ValidationContext $context) : mixed
Parameters
- $context : ValidationContext
Return values
mixed —getMaxQueryComplexity()
public
getMaxQueryComplexity() : mixed
Return values
mixed —getName()
public
getName() : mixed
Return values
mixed —getQueryComplexity()
public
getQueryComplexity() : mixed
Return values
mixed —getRawVariableValues()
public
getRawVariableValues() : 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()
public
getVisitor(ValidationContext $context) : mixed
Parameters
- $context : ValidationContext
Return values
mixed —maxQueryComplexityErrorMessage()
public
static maxQueryComplexityErrorMessage(mixed $max, mixed $count) : mixed
Parameters
- $max : mixed
- $count : mixed
Return values
mixed —setMaxQueryComplexity()
Set max query complexity. If equal to 0 no check is done. Must be greater or equal to 0.
public
setMaxQueryComplexity(mixed $maxQueryComplexity) : mixed
Parameters
- $maxQueryComplexity : mixed
Return values
mixed —setRawVariableValues()
public
setRawVariableValues([array<string|int, mixed>|null $rawVariableValues = null ]) : mixed
Parameters
- $rawVariableValues : array<string|int, mixed>|null = null
Return values
mixed —checkIfGreaterOrEqualToZero()
check if equal to 0 no check is done. Must be greater or equal to 0.
protected
checkIfGreaterOrEqualToZero(string $name, int $value) : mixed
Parameters
- $name : string
- $value : int
Return values
mixed —collectFieldASTsAndDefs()
Given a selectionSet, adds all of the fields in that selection to the passed in map of fields, and returns it at the end.
protected
collectFieldASTsAndDefs(ValidationContext $context, Type|null $parentType, SelectionSetNode $selectionSet[, ArrayObject|null $visitedFragmentNames = null ][, ArrayObject|null $astAndDefs = null ]) : ArrayObject
Note: This is not the same as execution's collectFields because at static time we do not know what object type will be used, so we unconditionally spread in all fragments.
Parameters
- $context : ValidationContext
- $parentType : Type|null
- $selectionSet : SelectionSetNode
- $visitedFragmentNames : ArrayObject|null = null
- $astAndDefs : ArrayObject|null = null
Tags
Return values
ArrayObject —gatherFragmentDefinition()
protected
gatherFragmentDefinition(ValidationContext $context) : mixed
Parameters
- $context : ValidationContext
Return values
mixed —getFieldName()
protected
getFieldName(FieldNode $node) : mixed
Parameters
- $node : FieldNode
Return values
mixed —getFragment()
protected
getFragment(FragmentSpreadNode $fragmentSpread) : mixed
Parameters
- $fragmentSpread : FragmentSpreadNode
Return values
mixed —getFragments()
protected
getFragments() : array<string|int, FragmentDefinitionNode>
Return values
array<string|int, FragmentDefinitionNode> —invokeIfNeeded()
protected
invokeIfNeeded(ValidationContext $context, array<string|int, callable> $validators) : array<string|int, callable>
Parameters
- $context : ValidationContext
- $validators : array<string|int, callable>
Return values
array<string|int, callable> —isEnabled()
protected
isEnabled() : mixed
Return values
mixed —astFieldInfo()
private
astFieldInfo(FieldNode $field) : mixed
Parameters
- $field : FieldNode
Return values
mixed —buildFieldArguments()
private
buildFieldArguments(FieldNode $node) : mixed
Parameters
- $node : FieldNode
Return values
mixed —directiveExcludesField()
private
directiveExcludesField(FieldNode $node) : mixed
Parameters
- $node : FieldNode
Return values
mixed —fieldComplexity()
private
fieldComplexity(mixed $node, mixed $complexity) : mixed
Parameters
- $node : mixed
- $complexity : mixed
Return values
mixed —nodeComplexity()
private
nodeComplexity(Node $node, mixed $complexity) : mixed
Parameters
- $node : Node
- $complexity : mixed