mirror of
https://github.com/retailcrm/graphql-php.git
synced 2024-11-22 12:56:05 +03:00
commit
f1fc5d66c9
1
.gitignore
vendored
1
.gitignore
vendored
@ -3,3 +3,4 @@ composer.phar
|
|||||||
composer.lock
|
composer.lock
|
||||||
vendor/
|
vendor/
|
||||||
bin/
|
bin/
|
||||||
|
phpstan.phar
|
||||||
|
13
.travis.yml
13
.travis.yml
@ -9,7 +9,13 @@ php:
|
|||||||
- 7.2
|
- 7.2
|
||||||
- nightly
|
- nightly
|
||||||
|
|
||||||
matrix:
|
jobs:
|
||||||
|
include:
|
||||||
|
- stage: Code Quality
|
||||||
|
php: 7.2
|
||||||
|
env: STATIC_ANALYSIS
|
||||||
|
install: travis_retry composer install --prefer-dist
|
||||||
|
script: composer static-analysis
|
||||||
allow_failures:
|
allow_failures:
|
||||||
- php: nightly
|
- php: nightly
|
||||||
|
|
||||||
@ -22,10 +28,7 @@ before_install:
|
|||||||
- phpenv config-rm xdebug.ini || true
|
- phpenv config-rm xdebug.ini || true
|
||||||
- composer selfupdate
|
- composer selfupdate
|
||||||
|
|
||||||
install:
|
install: composer install --dev --prefer-dist
|
||||||
- composer install --dev --prefer-dist
|
|
||||||
- composer require react/promise:2.*
|
|
||||||
- composer require psr/http-message:1.*
|
|
||||||
|
|
||||||
script: if [ "$TRAVIS_PHP_VERSION" == "5.6" ]; then bin/phpunit --coverage-clover build/logs/clover.xml --group default,ReactPromise; else bin/phpunit --group default,ReactPromise; fi
|
script: if [ "$TRAVIS_PHP_VERSION" == "5.6" ]; then bin/phpunit --coverage-clover build/logs/clover.xml --group default,ReactPromise; else bin/phpunit --group default,ReactPromise; fi
|
||||||
|
|
||||||
|
@ -14,13 +14,11 @@
|
|||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"phpunit/phpunit": "^4.8",
|
"phpunit/phpunit": "^4.8",
|
||||||
"psr/http-message": "^1.0"
|
"psr/http-message": "^1.0",
|
||||||
|
"react/promise": "2.*"
|
||||||
},
|
},
|
||||||
"config": {
|
"config": {
|
||||||
"bin-dir": "bin",
|
"bin-dir": "bin",
|
||||||
"platform": {
|
|
||||||
"php": "5.6.0"
|
|
||||||
},
|
|
||||||
"preferred-install": "dist",
|
"preferred-install": "dist",
|
||||||
"sort-packages": true
|
"sort-packages": true
|
||||||
},
|
},
|
||||||
@ -36,6 +34,15 @@
|
|||||||
"GraphQL\\Examples\\Blog\\": "examples/01-blog/Blog/"
|
"GraphQL\\Examples\\Blog\\": "examples/01-blog/Blog/"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"scripts": {
|
||||||
|
"static-analysis": [
|
||||||
|
"rm phpstan.phar || true",
|
||||||
|
"@composer req --ansi --no-interaction --dev phpstan/phpstan-shim",
|
||||||
|
"cp -f vendor/phpstan/phpstan-shim/phpstan.phar .",
|
||||||
|
"@composer rem --ansi --dev phpstan/phpstan-shim",
|
||||||
|
"@php phpstan.phar analyse --ansi -l 1 -c phpstan.neon src"
|
||||||
|
]
|
||||||
|
},
|
||||||
"suggest": {
|
"suggest": {
|
||||||
"react/promise": "To leverage async resolving on React PHP platform",
|
"react/promise": "To leverage async resolving on React PHP platform",
|
||||||
"psr/http-message": "To use standard GraphQL server"
|
"psr/http-message": "To use standard GraphQL server"
|
||||||
|
0
phpstan.neon
Normal file
0
phpstan.neon
Normal file
@ -2,6 +2,7 @@
|
|||||||
namespace GraphQL\Executor;
|
namespace GraphQL\Executor;
|
||||||
|
|
||||||
use GraphQL\Error\Error;
|
use GraphQL\Error\Error;
|
||||||
|
use GraphQL\Executor\Promise\PromiseAdapter;
|
||||||
use GraphQL\Language\AST\FragmentDefinitionNode;
|
use GraphQL\Language\AST\FragmentDefinitionNode;
|
||||||
use GraphQL\Language\AST\OperationDefinitionNode;
|
use GraphQL\Language\AST\OperationDefinitionNode;
|
||||||
use GraphQL\Type\Schema;
|
use GraphQL\Type\Schema;
|
||||||
@ -56,6 +57,11 @@ class ExecutionContext
|
|||||||
*/
|
*/
|
||||||
public $errors;
|
public $errors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var PromiseAdapter
|
||||||
|
*/
|
||||||
|
public $promises;
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
$schema,
|
$schema,
|
||||||
$fragments,
|
$fragments,
|
||||||
|
@ -560,7 +560,7 @@ class Executor
|
|||||||
switch ($selection->kind) {
|
switch ($selection->kind) {
|
||||||
case NodeKind::FIELD:
|
case NodeKind::FIELD:
|
||||||
if (!$this->shouldIncludeNode($selection)) {
|
if (!$this->shouldIncludeNode($selection)) {
|
||||||
continue;
|
continue 2;
|
||||||
}
|
}
|
||||||
$name = self::getFieldEntryKey($selection);
|
$name = self::getFieldEntryKey($selection);
|
||||||
if (!isset($fields[$name])) {
|
if (!isset($fields[$name])) {
|
||||||
@ -572,7 +572,7 @@ class Executor
|
|||||||
if (!$this->shouldIncludeNode($selection) ||
|
if (!$this->shouldIncludeNode($selection) ||
|
||||||
!$this->doesFragmentConditionMatch($selection, $runtimeType)
|
!$this->doesFragmentConditionMatch($selection, $runtimeType)
|
||||||
) {
|
) {
|
||||||
continue;
|
continue 2;
|
||||||
}
|
}
|
||||||
$this->collectFields(
|
$this->collectFields(
|
||||||
$runtimeType,
|
$runtimeType,
|
||||||
@ -584,14 +584,14 @@ class Executor
|
|||||||
case NodeKind::FRAGMENT_SPREAD:
|
case NodeKind::FRAGMENT_SPREAD:
|
||||||
$fragName = $selection->name->value;
|
$fragName = $selection->name->value;
|
||||||
if (!empty($visitedFragmentNames[$fragName]) || !$this->shouldIncludeNode($selection)) {
|
if (!empty($visitedFragmentNames[$fragName]) || !$this->shouldIncludeNode($selection)) {
|
||||||
continue;
|
continue 2;
|
||||||
}
|
}
|
||||||
$visitedFragmentNames[$fragName] = true;
|
$visitedFragmentNames[$fragName] = true;
|
||||||
|
|
||||||
/** @var FragmentDefinitionNode|null $fragment */
|
/** @var FragmentDefinitionNode|null $fragment */
|
||||||
$fragment = isset($exeContext->fragments[$fragName]) ? $exeContext->fragments[$fragName] : null;
|
$fragment = isset($exeContext->fragments[$fragName]) ? $exeContext->fragments[$fragName] : null;
|
||||||
if (!$fragment || !$this->doesFragmentConditionMatch($fragment, $runtimeType)) {
|
if (!$fragment || !$this->doesFragmentConditionMatch($fragment, $runtimeType)) {
|
||||||
continue;
|
continue 2;
|
||||||
}
|
}
|
||||||
$this->collectFields(
|
$this->collectFields(
|
||||||
$runtimeType,
|
$runtimeType,
|
||||||
|
@ -6,15 +6,6 @@ use GraphQL\Language\AST\NodeKind;
|
|||||||
use GraphQL\Language\AST\NodeList;
|
use GraphQL\Language\AST\NodeList;
|
||||||
use GraphQL\Utils\TypeInfo;
|
use GraphQL\Utils\TypeInfo;
|
||||||
|
|
||||||
class VisitorOperation
|
|
||||||
{
|
|
||||||
public $doBreak;
|
|
||||||
|
|
||||||
public $doContinue;
|
|
||||||
|
|
||||||
public $removeNode;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Utility for efficient AST traversal and modification.
|
* Utility for efficient AST traversal and modification.
|
||||||
*
|
*
|
||||||
@ -258,6 +249,7 @@ class Visitor
|
|||||||
|
|
||||||
if ($visitFn) {
|
if ($visitFn) {
|
||||||
$result = call_user_func($visitFn, $node, $key, $parent, $path, $ancestors);
|
$result = call_user_func($visitFn, $node, $key, $parent, $path, $ancestors);
|
||||||
|
$editValue = null;
|
||||||
|
|
||||||
if ($result !== null) {
|
if ($result !== null) {
|
||||||
if ($result instanceof VisitorOperation) {
|
if ($result instanceof VisitorOperation) {
|
||||||
|
11
src/Language/VisitorOperation.php
Normal file
11
src/Language/VisitorOperation.php
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
<?php
|
||||||
|
namespace GraphQL\Language;
|
||||||
|
|
||||||
|
class VisitorOperation
|
||||||
|
{
|
||||||
|
public $doBreak;
|
||||||
|
|
||||||
|
public $doContinue;
|
||||||
|
|
||||||
|
public $removeNode;
|
||||||
|
}
|
@ -5,7 +5,7 @@ use GraphQL\Error\FormattedError;
|
|||||||
use GraphQL\Error\InvariantViolation;
|
use GraphQL\Error\InvariantViolation;
|
||||||
use GraphQL\Executor\ExecutionResult;
|
use GraphQL\Executor\ExecutionResult;
|
||||||
use GraphQL\Executor\Promise\Promise;
|
use GraphQL\Executor\Promise\Promise;
|
||||||
use GraphQL\Utils;
|
use GraphQL\Utils\Utils;
|
||||||
use Psr\Http\Message\ResponseInterface;
|
use Psr\Http\Message\ResponseInterface;
|
||||||
use Psr\Http\Message\ServerRequestInterface;
|
use Psr\Http\Message\ServerRequestInterface;
|
||||||
use Psr\Http\Message\StreamInterface;
|
use Psr\Http\Message\StreamInterface;
|
||||||
|
@ -62,6 +62,11 @@ class FieldDefinition
|
|||||||
*/
|
*/
|
||||||
public $config;
|
public $config;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var null|callable
|
||||||
|
*/
|
||||||
|
public $complexityFn;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var OutputType
|
* @var OutputType
|
||||||
*/
|
*/
|
||||||
@ -108,7 +113,7 @@ class FieldDefinition
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array|Config $field
|
* @param array $field
|
||||||
* @param string $typeName
|
* @param string $typeName
|
||||||
* @return FieldDefinition
|
* @return FieldDefinition
|
||||||
*/
|
*/
|
||||||
|
@ -24,7 +24,7 @@ class InputObjectField
|
|||||||
public $description;
|
public $description;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var callback|InputType
|
* @var callable|InputType
|
||||||
*/
|
*/
|
||||||
public $type;
|
public $type;
|
||||||
|
|
||||||
|
@ -49,10 +49,10 @@ class VariablesDefaultValueAllowed extends AbstractValidationRule
|
|||||||
|
|
||||||
return Visitor::skipNode();
|
return Visitor::skipNode();
|
||||||
},
|
},
|
||||||
NodeKind::SELECTION_SET => function(SelectionSetNode $node) use ($context) {
|
NodeKind::SELECTION_SET => function(SelectionSetNode $node) {
|
||||||
return Visitor::skipNode();
|
return Visitor::skipNode();
|
||||||
},
|
},
|
||||||
NodeKind::FRAGMENT_DEFINITION => function(FragmentDefinitionNode $node) use ($context) {
|
NodeKind::FRAGMENT_DEFINITION => function(FragmentDefinitionNode $node) {
|
||||||
return Visitor::skipNode();
|
return Visitor::skipNode();
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
Loading…
Reference in New Issue
Block a user