mirror of
https://github.com/retailcrm/graphql-php.git
synced 2024-11-25 14:26:08 +03:00
Cleaning up old unused messages
This commit is contained in:
parent
a165c3aaab
commit
c5bba0e7d4
@ -1,139 +0,0 @@
|
|||||||
<?php
|
|
||||||
namespace GraphQL\Validator;
|
|
||||||
|
|
||||||
use GraphQL\Utils;
|
|
||||||
|
|
||||||
class Messages
|
|
||||||
{
|
|
||||||
static function missingArgMessage($fieldName, $argName, $typeName)
|
|
||||||
{
|
|
||||||
return "Field $fieldName argument $argName of type $typeName, is required but not provided.";
|
|
||||||
}
|
|
||||||
|
|
||||||
static function badValueMessage($argName, $typeName, $value)
|
|
||||||
{
|
|
||||||
return "Argument $argName expected type $typeName but got: $value.";
|
|
||||||
}
|
|
||||||
|
|
||||||
static function fragmentOnNonCompositeErrorMessage($fragName, $typeName)
|
|
||||||
{
|
|
||||||
return "Fragment $fragName cannot condition on non composite type \"$typeName\".";
|
|
||||||
}
|
|
||||||
|
|
||||||
static function inlineFragmentOnNonCompositeErrorMessage($typeName)
|
|
||||||
{
|
|
||||||
return "Fragment cannot condition on non composite type \"$typeName\".";
|
|
||||||
}
|
|
||||||
|
|
||||||
static function unknownArgMessage($argName, $fieldName, $typeName)
|
|
||||||
{
|
|
||||||
return "Unknown argument $argName on field $fieldName of type $typeName.";
|
|
||||||
}
|
|
||||||
|
|
||||||
static function unknownTypeMessage($typeName)
|
|
||||||
{
|
|
||||||
return "Unknown type $typeName.";
|
|
||||||
}
|
|
||||||
|
|
||||||
static function undefinedVarMessage($varName)
|
|
||||||
{
|
|
||||||
return "Variable \$$varName is not defined.";
|
|
||||||
}
|
|
||||||
|
|
||||||
static function undefinedVarByOpMessage($varName, $opName)
|
|
||||||
{
|
|
||||||
return "Variable \$$varName is not defined by operation $opName.";
|
|
||||||
}
|
|
||||||
|
|
||||||
static function unusedFragMessage($fragName)
|
|
||||||
{
|
|
||||||
return "Fragment $fragName is not used.";
|
|
||||||
}
|
|
||||||
|
|
||||||
static function unusedVariableMessage($varName)
|
|
||||||
{
|
|
||||||
return "Variable \$$varName is not used.";
|
|
||||||
}
|
|
||||||
|
|
||||||
static function typeIncompatibleSpreadMessage($fragName, $parentType, $fragType)
|
|
||||||
{
|
|
||||||
return "Fragment \"$fragName\" cannot be spread here as objects of " .
|
|
||||||
"type \"$parentType\" can never be of type \"$fragType\".";
|
|
||||||
}
|
|
||||||
|
|
||||||
static function typeIncompatibleAnonSpreadMessage($parentType, $fragType)
|
|
||||||
{
|
|
||||||
return "Fragment cannot be spread here as objects of " .
|
|
||||||
"type \"$parentType\" can never be of type \"$fragType\".";
|
|
||||||
}
|
|
||||||
|
|
||||||
static function noSubselectionAllowedMessage($field, $type)
|
|
||||||
{
|
|
||||||
return "Field \"$field\" of type $type must not have a sub selection.";
|
|
||||||
}
|
|
||||||
|
|
||||||
static function requiredSubselectionMessage($field, $type)
|
|
||||||
{
|
|
||||||
return "Field \"$field\" of type $type must have a sub selection.";
|
|
||||||
}
|
|
||||||
|
|
||||||
static function nonInputTypeOnVarMessage($variableName, $typeName)
|
|
||||||
{
|
|
||||||
return "Variable $${variableName} cannot be non input type $typeName.";
|
|
||||||
}
|
|
||||||
|
|
||||||
static function cycleErrorMessage($fragmentName, $spreadNames)
|
|
||||||
{
|
|
||||||
return "Cannot spread fragment $fragmentName within itself" .
|
|
||||||
(!empty($spreadNames) ? (" via " . implode(', ', $spreadNames)) : '') . '.';
|
|
||||||
}
|
|
||||||
|
|
||||||
static function unknownDirectiveMessage($directiveName)
|
|
||||||
{
|
|
||||||
return "Unknown directive $directiveName.";
|
|
||||||
}
|
|
||||||
|
|
||||||
static function misplacedDirectiveMessage($directiveName, $placement)
|
|
||||||
{
|
|
||||||
return "Directive $directiveName may not be used on $placement.";
|
|
||||||
}
|
|
||||||
|
|
||||||
static function missingDirectiveValueMessage($directiveName, $typeName)
|
|
||||||
{
|
|
||||||
return "Directive $directiveName expects a value of type $typeName.";
|
|
||||||
}
|
|
||||||
|
|
||||||
static function noDirectiveValueMessage($directiveName)
|
|
||||||
{
|
|
||||||
return "Directive $directiveName expects no value.";
|
|
||||||
}
|
|
||||||
|
|
||||||
static function badDirectiveValueMessage($directiveName, $typeName, $value)
|
|
||||||
{
|
|
||||||
return "Directive $directiveName expected type $typeName but " .
|
|
||||||
"got: $value.";
|
|
||||||
}
|
|
||||||
|
|
||||||
static function fieldsConflictMessage($responseName, $reason)
|
|
||||||
{
|
|
||||||
$reasonMessage = self::reasonMessage($reason);
|
|
||||||
return "Fields $responseName conflict because {$reasonMessage}.";
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param array|string $reason
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
private static function reasonMessage($reason)
|
|
||||||
{
|
|
||||||
if (is_array($reason)) {
|
|
||||||
$tmp = array_map(function($tmp) {
|
|
||||||
list($responseName, $subReason) = $tmp;
|
|
||||||
$reasonMessage = self::reasonMessage($subReason);
|
|
||||||
return "subfields $responseName conflict because $reasonMessage";
|
|
||||||
}, $reason);
|
|
||||||
return implode(' and ', $tmp);
|
|
||||||
}
|
|
||||||
return $reason;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,18 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace GraphQL\Validator\Rules;
|
namespace GraphQL\Validator\Rules;
|
||||||
|
|
||||||
|
|
||||||
use GraphQL\Error\Error;
|
use GraphQL\Error\Error;
|
||||||
use GraphQL\Language\AST\ArgumentNode;
|
use GraphQL\Language\AST\ArgumentNode;
|
||||||
use GraphQL\Language\AST\FieldNode;
|
|
||||||
use GraphQL\Language\AST\Node;
|
|
||||||
use GraphQL\Language\AST\NodeKind;
|
use GraphQL\Language\AST\NodeKind;
|
||||||
use GraphQL\Language\Printer;
|
use GraphQL\Language\Printer;
|
||||||
use GraphQL\Language\Visitor;
|
use GraphQL\Language\Visitor;
|
||||||
use GraphQL\Type\Definition\NonNull;
|
|
||||||
use GraphQL\Utils;
|
|
||||||
use GraphQL\Validator\DocumentValidator;
|
use GraphQL\Validator\DocumentValidator;
|
||||||
use GraphQL\Validator\Messages;
|
|
||||||
use GraphQL\Validator\ValidationContext;
|
use GraphQL\Validator\ValidationContext;
|
||||||
|
|
||||||
class ArgumentsOfCorrectType
|
class ArgumentsOfCorrectType
|
||||||
|
@ -1,15 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace GraphQL\Validator\Rules;
|
namespace GraphQL\Validator\Rules;
|
||||||
|
|
||||||
|
|
||||||
use GraphQL\Error\Error;
|
use GraphQL\Error\Error;
|
||||||
use GraphQL\Language\AST\FieldNode;
|
use GraphQL\Language\AST\FieldNode;
|
||||||
use GraphQL\Language\AST\Node;
|
|
||||||
use GraphQL\Language\AST\NodeKind;
|
use GraphQL\Language\AST\NodeKind;
|
||||||
use GraphQL\Schema;
|
use GraphQL\Schema;
|
||||||
use GraphQL\Type\Definition\AbstractType;
|
use GraphQL\Type\Definition\AbstractType;
|
||||||
use GraphQL\Utils;
|
use GraphQL\Utils;
|
||||||
use GraphQL\Validator\Messages;
|
|
||||||
use GraphQL\Validator\ValidationContext;
|
use GraphQL\Validator\ValidationContext;
|
||||||
|
|
||||||
class FieldsOnCorrectType
|
class FieldsOnCorrectType
|
||||||
|
@ -1,16 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace GraphQL\Validator\Rules;
|
namespace GraphQL\Validator\Rules;
|
||||||
|
|
||||||
|
|
||||||
use GraphQL\Error\Error;
|
use GraphQL\Error\Error;
|
||||||
use GraphQL\Language\AST\FragmentDefinitionNode;
|
use GraphQL\Language\AST\FragmentDefinitionNode;
|
||||||
use GraphQL\Language\AST\InlineFragmentNode;
|
use GraphQL\Language\AST\InlineFragmentNode;
|
||||||
use GraphQL\Language\AST\Node;
|
|
||||||
use GraphQL\Language\AST\NodeKind;
|
use GraphQL\Language\AST\NodeKind;
|
||||||
use GraphQL\Language\Printer;
|
use GraphQL\Language\Printer;
|
||||||
use GraphQL\Type\Definition\CompositeType;
|
|
||||||
use GraphQL\Type\Definition\Type;
|
use GraphQL\Type\Definition\Type;
|
||||||
use GraphQL\Validator\Messages;
|
|
||||||
use GraphQL\Validator\ValidationContext;
|
use GraphQL\Validator\ValidationContext;
|
||||||
|
|
||||||
class FragmentsOnCompositeTypes
|
class FragmentsOnCompositeTypes
|
||||||
|
@ -1,13 +1,10 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace GraphQL\Validator\Rules;
|
namespace GraphQL\Validator\Rules;
|
||||||
|
|
||||||
|
|
||||||
use GraphQL\Error\Error;
|
use GraphQL\Error\Error;
|
||||||
use GraphQL\Language\AST\ArgumentNode;
|
use GraphQL\Language\AST\ArgumentNode;
|
||||||
use GraphQL\Language\AST\Node;
|
|
||||||
use GraphQL\Language\AST\NodeKind;
|
use GraphQL\Language\AST\NodeKind;
|
||||||
use GraphQL\Utils;
|
use GraphQL\Utils;
|
||||||
use GraphQL\Validator\Messages;
|
|
||||||
use GraphQL\Validator\ValidationContext;
|
use GraphQL\Validator\ValidationContext;
|
||||||
|
|
||||||
class KnownArgumentNames
|
class KnownArgumentNames
|
||||||
|
@ -1,17 +1,10 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace GraphQL\Validator\Rules;
|
namespace GraphQL\Validator\Rules;
|
||||||
|
|
||||||
|
|
||||||
use GraphQL\Error\Error;
|
use GraphQL\Error\Error;
|
||||||
use GraphQL\Language\AST\FragmentDefinitionNode;
|
|
||||||
use GraphQL\Language\AST\FragmentSpreadNode;
|
|
||||||
use GraphQL\Language\AST\Node;
|
|
||||||
use GraphQL\Language\AST\NodeKind;
|
use GraphQL\Language\AST\NodeKind;
|
||||||
use GraphQL\Language\AST\OperationDefinitionNode;
|
use GraphQL\Language\AST\OperationDefinitionNode;
|
||||||
use GraphQL\Language\AST\VariableNode;
|
|
||||||
use GraphQL\Language\AST\VariableDefinitionNode;
|
use GraphQL\Language\AST\VariableDefinitionNode;
|
||||||
use GraphQL\Language\Visitor;
|
|
||||||
use GraphQL\Validator\Messages;
|
|
||||||
use GraphQL\Validator\ValidationContext;
|
use GraphQL\Validator\ValidationContext;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,14 +1,10 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace GraphQL\Validator\Rules;
|
namespace GraphQL\Validator\Rules;
|
||||||
|
|
||||||
|
|
||||||
use GraphQL\Error\Error;
|
use GraphQL\Error\Error;
|
||||||
use GraphQL\Language\AST\FragmentDefinitionNode;
|
use GraphQL\Language\AST\FragmentDefinitionNode;
|
||||||
use GraphQL\Language\AST\FragmentSpreadNode;
|
|
||||||
use GraphQL\Language\AST\Node;
|
|
||||||
use GraphQL\Language\AST\NodeKind;
|
use GraphQL\Language\AST\NodeKind;
|
||||||
use GraphQL\Language\Visitor;
|
use GraphQL\Language\Visitor;
|
||||||
use GraphQL\Validator\Messages;
|
|
||||||
use GraphQL\Validator\ValidationContext;
|
use GraphQL\Validator\ValidationContext;
|
||||||
|
|
||||||
class NoUnusedFragments
|
class NoUnusedFragments
|
||||||
|
@ -1,13 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace GraphQL\Validator\Rules;
|
namespace GraphQL\Validator\Rules;
|
||||||
|
|
||||||
|
|
||||||
use GraphQL\Error\Error;
|
use GraphQL\Error\Error;
|
||||||
use GraphQL\Language\AST\Node;
|
|
||||||
use GraphQL\Language\AST\NodeKind;
|
use GraphQL\Language\AST\NodeKind;
|
||||||
use GraphQL\Language\AST\OperationDefinitionNode;
|
use GraphQL\Language\AST\OperationDefinitionNode;
|
||||||
use GraphQL\Language\Visitor;
|
|
||||||
use GraphQL\Validator\Messages;
|
|
||||||
use GraphQL\Validator\ValidationContext;
|
use GraphQL\Validator\ValidationContext;
|
||||||
|
|
||||||
class NoUnusedVariables
|
class NoUnusedVariables
|
||||||
|
@ -1,13 +1,10 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace GraphQL\Validator\Rules;
|
namespace GraphQL\Validator\Rules;
|
||||||
|
|
||||||
|
|
||||||
use GraphQL\Error\Error;
|
use GraphQL\Error\Error;
|
||||||
use GraphQL\Language\AST\FieldNode;
|
use GraphQL\Language\AST\FieldNode;
|
||||||
use GraphQL\Language\AST\Node;
|
|
||||||
use GraphQL\Language\AST\NodeKind;
|
use GraphQL\Language\AST\NodeKind;
|
||||||
use GraphQL\Type\Definition\Type;
|
use GraphQL\Type\Definition\Type;
|
||||||
use GraphQL\Validator\Messages;
|
|
||||||
use GraphQL\Validator\ValidationContext;
|
use GraphQL\Validator\ValidationContext;
|
||||||
|
|
||||||
class ScalarLeafs
|
class ScalarLeafs
|
||||||
|
@ -1,19 +1,13 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace GraphQL\Validator\Rules;
|
namespace GraphQL\Validator\Rules;
|
||||||
|
|
||||||
|
|
||||||
use GraphQL\Error\Error;
|
use GraphQL\Error\Error;
|
||||||
use GraphQL\Language\AST\FragmentSpreadNode;
|
|
||||||
use GraphQL\Language\AST\Node;
|
|
||||||
use GraphQL\Language\AST\NodeKind;
|
use GraphQL\Language\AST\NodeKind;
|
||||||
use GraphQL\Language\AST\OperationDefinitionNode;
|
use GraphQL\Language\AST\OperationDefinitionNode;
|
||||||
use GraphQL\Language\AST\VariableNode;
|
|
||||||
use GraphQL\Language\AST\VariableDefinitionNode;
|
use GraphQL\Language\AST\VariableDefinitionNode;
|
||||||
use GraphQL\Language\Visitor;
|
|
||||||
use GraphQL\Type\Definition\ListOfType;
|
use GraphQL\Type\Definition\ListOfType;
|
||||||
use GraphQL\Type\Definition\NonNull;
|
use GraphQL\Type\Definition\NonNull;
|
||||||
use GraphQL\Utils\TypeInfo;
|
use GraphQL\Utils\TypeInfo;
|
||||||
use GraphQL\Validator\Messages;
|
|
||||||
use GraphQL\Validator\ValidationContext;
|
use GraphQL\Validator\ValidationContext;
|
||||||
|
|
||||||
class VariablesInAllowedPosition
|
class VariablesInAllowedPosition
|
||||||
|
@ -3,7 +3,6 @@ namespace GraphQL\Tests\Validator;
|
|||||||
|
|
||||||
use GraphQL\Error\FormattedError;
|
use GraphQL\Error\FormattedError;
|
||||||
use GraphQL\Language\SourceLocation;
|
use GraphQL\Language\SourceLocation;
|
||||||
use GraphQL\Validator\Messages;
|
|
||||||
use GraphQL\Validator\Rules\DefaultValuesOfCorrectType;
|
use GraphQL\Validator\Rules\DefaultValuesOfCorrectType;
|
||||||
|
|
||||||
class DefaultValuesOfCorrectTypeTest extends TestCase
|
class DefaultValuesOfCorrectTypeTest extends TestCase
|
||||||
|
@ -3,7 +3,6 @@ namespace GraphQL\Tests\Validator;
|
|||||||
|
|
||||||
use GraphQL\Error\FormattedError;
|
use GraphQL\Error\FormattedError;
|
||||||
use GraphQL\Language\SourceLocation;
|
use GraphQL\Language\SourceLocation;
|
||||||
use GraphQL\Validator\Messages;
|
|
||||||
use GraphQL\Validator\Rules\FieldsOnCorrectType;
|
use GraphQL\Validator\Rules\FieldsOnCorrectType;
|
||||||
|
|
||||||
class FieldsOnCorrectTypeTest extends TestCase
|
class FieldsOnCorrectTypeTest extends TestCase
|
||||||
|
@ -3,7 +3,6 @@ namespace GraphQL\Tests\Validator;
|
|||||||
|
|
||||||
use GraphQL\Error\FormattedError;
|
use GraphQL\Error\FormattedError;
|
||||||
use GraphQL\Language\SourceLocation;
|
use GraphQL\Language\SourceLocation;
|
||||||
use GraphQL\Validator\Messages;
|
|
||||||
use GraphQL\Validator\Rules\VariablesInAllowedPosition;
|
use GraphQL\Validator\Rules\VariablesInAllowedPosition;
|
||||||
|
|
||||||
class VariablesInAllowedPositionTest extends TestCase
|
class VariablesInAllowedPositionTest extends TestCase
|
||||||
|
Loading…
Reference in New Issue
Block a user