mirror of
https://github.com/retailcrm/graphql-php.git
synced 2024-11-25 14:26:08 +03:00
commit
f1fc5d66c9
1
.gitignore
vendored
1
.gitignore
vendored
@ -3,3 +3,4 @@ composer.phar
|
||||
composer.lock
|
||||
vendor/
|
||||
bin/
|
||||
phpstan.phar
|
||||
|
13
.travis.yml
13
.travis.yml
@ -9,7 +9,13 @@ php:
|
||||
- 7.2
|
||||
- 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:
|
||||
- php: nightly
|
||||
|
||||
@ -22,10 +28,7 @@ before_install:
|
||||
- phpenv config-rm xdebug.ini || true
|
||||
- composer selfupdate
|
||||
|
||||
install:
|
||||
- composer install --dev --prefer-dist
|
||||
- composer require react/promise:2.*
|
||||
- composer require psr/http-message:1.*
|
||||
install: composer install --dev --prefer-dist
|
||||
|
||||
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": {
|
||||
"phpunit/phpunit": "^4.8",
|
||||
"psr/http-message": "^1.0"
|
||||
"psr/http-message": "^1.0",
|
||||
"react/promise": "2.*"
|
||||
},
|
||||
"config": {
|
||||
"bin-dir": "bin",
|
||||
"platform": {
|
||||
"php": "5.6.0"
|
||||
},
|
||||
"preferred-install": "dist",
|
||||
"sort-packages": true
|
||||
},
|
||||
@ -36,6 +34,15 @@
|
||||
"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": {
|
||||
"react/promise": "To leverage async resolving on React PHP platform",
|
||||
"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;
|
||||
|
||||
use GraphQL\Error\Error;
|
||||
use GraphQL\Executor\Promise\PromiseAdapter;
|
||||
use GraphQL\Language\AST\FragmentDefinitionNode;
|
||||
use GraphQL\Language\AST\OperationDefinitionNode;
|
||||
use GraphQL\Type\Schema;
|
||||
@ -56,6 +57,11 @@ class ExecutionContext
|
||||
*/
|
||||
public $errors;
|
||||
|
||||
/**
|
||||
* @var PromiseAdapter
|
||||
*/
|
||||
public $promises;
|
||||
|
||||
public function __construct(
|
||||
$schema,
|
||||
$fragments,
|
||||
|
@ -560,7 +560,7 @@ class Executor
|
||||
switch ($selection->kind) {
|
||||
case NodeKind::FIELD:
|
||||
if (!$this->shouldIncludeNode($selection)) {
|
||||
continue;
|
||||
continue 2;
|
||||
}
|
||||
$name = self::getFieldEntryKey($selection);
|
||||
if (!isset($fields[$name])) {
|
||||
@ -572,7 +572,7 @@ class Executor
|
||||
if (!$this->shouldIncludeNode($selection) ||
|
||||
!$this->doesFragmentConditionMatch($selection, $runtimeType)
|
||||
) {
|
||||
continue;
|
||||
continue 2;
|
||||
}
|
||||
$this->collectFields(
|
||||
$runtimeType,
|
||||
@ -584,14 +584,14 @@ class Executor
|
||||
case NodeKind::FRAGMENT_SPREAD:
|
||||
$fragName = $selection->name->value;
|
||||
if (!empty($visitedFragmentNames[$fragName]) || !$this->shouldIncludeNode($selection)) {
|
||||
continue;
|
||||
continue 2;
|
||||
}
|
||||
$visitedFragmentNames[$fragName] = true;
|
||||
|
||||
/** @var FragmentDefinitionNode|null $fragment */
|
||||
$fragment = isset($exeContext->fragments[$fragName]) ? $exeContext->fragments[$fragName] : null;
|
||||
if (!$fragment || !$this->doesFragmentConditionMatch($fragment, $runtimeType)) {
|
||||
continue;
|
||||
continue 2;
|
||||
}
|
||||
$this->collectFields(
|
||||
$runtimeType,
|
||||
|
@ -6,15 +6,6 @@ use GraphQL\Language\AST\NodeKind;
|
||||
use GraphQL\Language\AST\NodeList;
|
||||
use GraphQL\Utils\TypeInfo;
|
||||
|
||||
class VisitorOperation
|
||||
{
|
||||
public $doBreak;
|
||||
|
||||
public $doContinue;
|
||||
|
||||
public $removeNode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Utility for efficient AST traversal and modification.
|
||||
*
|
||||
@ -258,6 +249,7 @@ class Visitor
|
||||
|
||||
if ($visitFn) {
|
||||
$result = call_user_func($visitFn, $node, $key, $parent, $path, $ancestors);
|
||||
$editValue = null;
|
||||
|
||||
if ($result !== null) {
|
||||
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\Executor\ExecutionResult;
|
||||
use GraphQL\Executor\Promise\Promise;
|
||||
use GraphQL\Utils;
|
||||
use GraphQL\Utils\Utils;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use Psr\Http\Message\StreamInterface;
|
||||
|
@ -62,6 +62,11 @@ class FieldDefinition
|
||||
*/
|
||||
public $config;
|
||||
|
||||
/**
|
||||
* @var null|callable
|
||||
*/
|
||||
public $complexityFn;
|
||||
|
||||
/**
|
||||
* @var OutputType
|
||||
*/
|
||||
@ -108,7 +113,7 @@ class FieldDefinition
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array|Config $field
|
||||
* @param array $field
|
||||
* @param string $typeName
|
||||
* @return FieldDefinition
|
||||
*/
|
||||
|
@ -24,7 +24,7 @@ class InputObjectField
|
||||
public $description;
|
||||
|
||||
/**
|
||||
* @var callback|InputType
|
||||
* @var callable|InputType
|
||||
*/
|
||||
public $type;
|
||||
|
||||
|
@ -49,10 +49,10 @@ class VariablesDefaultValueAllowed extends AbstractValidationRule
|
||||
|
||||
return Visitor::skipNode();
|
||||
},
|
||||
NodeKind::SELECTION_SET => function(SelectionSetNode $node) use ($context) {
|
||||
NodeKind::SELECTION_SET => function(SelectionSetNode $node) {
|
||||
return Visitor::skipNode();
|
||||
},
|
||||
NodeKind::FRAGMENT_DEFINITION => function(FragmentDefinitionNode $node) use ($context) {
|
||||
NodeKind::FRAGMENT_DEFINITION => function(FragmentDefinitionNode $node) {
|
||||
return Visitor::skipNode();
|
||||
},
|
||||
];
|
||||
|
Loading…
Reference in New Issue
Block a user