QueryComplexity
extends QuerySecurityRule
in package
Tags
Table of Contents
- DISABLED = 0
- $context : QueryValidationContext
- $fieldNodeAndDefs : ArrayObject
- $fragments : array<string|int, mixed>
- $maxQueryComplexity : int
- $name : string
- $queryComplexity : int
- $rawVariableValues : array<string|int, mixed>
- $variableDefs : NodeList
- __construct() : mixed
- getMaxQueryComplexity() : int
- getName() : string
- getQueryComplexity() : int
- Complexity of the first operation exceeding the defined limit, or, in case no operation exceeds the limit, complexity of the last defined operation.
- getRawVariableValues() : array<string, mixed>
- getSDLVisitor() : array<string|int, mixed>
- Returns structure suitable for @see \Automattic\WooCommerce\Vendor\GraphQL\Language\Visitor.
- getVisitor() : array<string|int, mixed>
- maxQueryComplexityErrorMessage() : string
- setMaxQueryComplexity() : void
- Set max query complexity. If equal to 0 no check is done. Must be greater or equal to 0.
- setRawVariableValues() : void
- buildFieldArguments() : array<string, mixed>
- checkIfGreaterOrEqualToZero() : void
- collectFieldASTsAndDefs() : ArrayObject
- Given a selectionSet, adds all fields in that selection to the passed in map of fields, and returns it at the end.
- directiveExcludesField() : bool
- Will the given field be executed at all, given the directives placed upon it?
- fieldComplexity() : int
- fieldDefinition() : FieldDefinition|null
- gatherFragmentDefinition() : void
- getFieldName() : string
- getFragment() : FragmentDefinitionNode|null
- getFragments() : array<string, FragmentDefinitionNode>
- invokeIfNeeded() : array<string|int, mixed>
- isEnabled() : bool
- nodeComplexity() : int
Constants
DISABLED
public
mixed
DISABLED
= ""
Properties
$context
protected
QueryValidationContext
$context
$fieldNodeAndDefs
protected
ArrayObject
$fieldNodeAndDefs
Tags
$fragments
protected
array<string|int, mixed>
$fragments
= []
$maxQueryComplexity
protected
int
$maxQueryComplexity
$name
protected
string
$name
$queryComplexity
protected
int
$queryComplexity
$rawVariableValues
protected
array<string|int, mixed>
$rawVariableValues
= []
$variableDefs
protected
NodeList
$variableDefs
Methods
__construct()
public
__construct(int $maxQueryComplexity) : mixed
Parameters
- $maxQueryComplexity : int
Tags
Return values
mixed —getMaxQueryComplexity()
public
getMaxQueryComplexity() : int
Return values
int —getName()
public
getName() : string
Return values
string —getQueryComplexity()
Complexity of the first operation exceeding the defined limit, or, in case no operation exceeds the limit, complexity of the last defined operation.
public
getQueryComplexity() : int
Return values
int —getRawVariableValues()
public
getRawVariableValues() : array<string, mixed>
Return values
array<string, mixed> —getSDLVisitor()
Returns structure suitable for @see \Automattic\WooCommerce\Vendor\GraphQL\Language\Visitor.
public
getSDLVisitor(SDLValidationContext $context) : array<string|int, mixed>
Parameters
- $context : SDLValidationContext
Tags
Return values
array<string|int, mixed> —getVisitor()
public
getVisitor(QueryValidationContext $context) : array<string|int, mixed>
Parameters
- $context : QueryValidationContext
Return values
array<string|int, mixed> —maxQueryComplexityErrorMessage()
public
static maxQueryComplexityErrorMessage(int $max, int $count) : string
Parameters
- $max : int
- $count : int
Return values
string —setMaxQueryComplexity()
Set max query complexity. If equal to 0 no check is done. Must be greater or equal to 0.
public
setMaxQueryComplexity(int $maxQueryComplexity) : void
Parameters
- $maxQueryComplexity : int
Tags
Return values
void —setRawVariableValues()
public
setRawVariableValues([array<string, mixed>|null $rawVariableValues = null ]) : void
Parameters
- $rawVariableValues : array<string, mixed>|null = null
Return values
void —buildFieldArguments()
protected
buildFieldArguments(FieldNode $node) : array<string, mixed>
Parameters
- $node : FieldNode
Tags
Return values
array<string, mixed> —checkIfGreaterOrEqualToZero()
protected
checkIfGreaterOrEqualToZero(string $name, int $value) : void
Parameters
- $name : string
- $value : int
Tags
Return values
void —collectFieldASTsAndDefs()
Given a selectionSet, adds all fields in that selection to the passed in map of fields, and returns it at the end.
protected
collectFieldASTsAndDefs(QueryValidationContext $context, Type|null $parentType, SelectionSetNode $selectionSet[, ArrayObject<string, true>|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 : QueryValidationContext
- $parentType : Type|null
- $selectionSet : SelectionSetNode
- $visitedFragmentNames : ArrayObject<string, true>|null = null
- $astAndDefs : ArrayObject|null = null
Tags
Return values
ArrayObject —directiveExcludesField()
Will the given field be executed at all, given the directives placed upon it?
protected
directiveExcludesField(FieldNode $node) : bool
Parameters
- $node : FieldNode
Tags
Return values
bool —fieldComplexity()
protected
fieldComplexity(SelectionSetNode $selectionSet) : int
Parameters
- $selectionSet : SelectionSetNode
Tags
Return values
int —fieldDefinition()
protected
fieldDefinition(FieldNode $field) : FieldDefinition|null
Parameters
- $field : FieldNode
Return values
FieldDefinition|null —gatherFragmentDefinition()
protected
gatherFragmentDefinition(QueryValidationContext $context) : void
Parameters
- $context : QueryValidationContext
Return values
void —getFieldName()
protected
getFieldName(FieldNode $node) : string
Parameters
- $node : FieldNode
Return values
string —getFragment()
protected
getFragment(FragmentSpreadNode $fragmentSpread) : FragmentDefinitionNode|null
Parameters
- $fragmentSpread : FragmentSpreadNode
Return values
FragmentDefinitionNode|null —getFragments()
protected
getFragments() : array<string, FragmentDefinitionNode>
Return values
array<string, FragmentDefinitionNode> —invokeIfNeeded()
protected
invokeIfNeeded(QueryValidationContext $context, array<string|int, mixed> $validators) : array<string|int, mixed>
Parameters
- $context : QueryValidationContext
- $validators : array<string|int, mixed>
Tags
Return values
array<string|int, mixed> —isEnabled()
protected
isEnabled() : bool
Return values
bool —nodeComplexity()
protected
nodeComplexity(SelectionNode $node) : int
Parameters
- $node : SelectionNode
