2015-08-17 17:01:55 +03:00
|
|
|
<?php
|
2016-04-09 10:36:53 +03:00
|
|
|
namespace GraphQL\Tests\Executor;
|
2015-08-17 17:01:55 +03:00
|
|
|
|
|
|
|
use GraphQL\Type\Definition\ScalarType;
|
2018-02-09 13:26:22 +03:00
|
|
|
use GraphQL\Utils\Utils;
|
2015-08-17 17:01:55 +03:00
|
|
|
|
|
|
|
class Dog
|
|
|
|
{
|
|
|
|
function __construct($name, $woofs)
|
|
|
|
{
|
|
|
|
$this->name = $name;
|
|
|
|
$this->woofs = $woofs;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class Cat
|
|
|
|
{
|
|
|
|
function __construct($name, $meows)
|
|
|
|
{
|
|
|
|
$this->name = $name;
|
|
|
|
$this->meows = $meows;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class Human
|
|
|
|
{
|
|
|
|
function __construct($name)
|
|
|
|
{
|
|
|
|
$this->name = $name;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class Person
|
|
|
|
{
|
|
|
|
public $name;
|
|
|
|
public $pets;
|
|
|
|
public $friends;
|
|
|
|
|
|
|
|
function __construct($name, $pets = null, $friends = null)
|
|
|
|
{
|
|
|
|
$this->name = $name;
|
|
|
|
$this->pets = $pets;
|
|
|
|
$this->friends = $friends;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class ComplexScalar extends ScalarType
|
|
|
|
{
|
|
|
|
public static function create()
|
|
|
|
{
|
|
|
|
return new self();
|
|
|
|
}
|
|
|
|
|
|
|
|
public $name = 'ComplexScalar';
|
|
|
|
|
|
|
|
public function serialize($value)
|
|
|
|
{
|
|
|
|
if ($value === 'DeserializedValue') {
|
|
|
|
return 'SerializedValue';
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function parseValue($value)
|
|
|
|
{
|
|
|
|
if ($value === 'SerializedValue') {
|
|
|
|
return 'DeserializedValue';
|
|
|
|
}
|
2018-02-09 13:26:22 +03:00
|
|
|
return Utils::undefined();
|
2015-08-17 17:01:55 +03:00
|
|
|
}
|
|
|
|
|
2018-02-09 13:26:22 +03:00
|
|
|
public function parseLiteral($valueNode, array $variables = null)
|
2015-08-17 17:01:55 +03:00
|
|
|
{
|
2016-11-19 02:47:55 +03:00
|
|
|
if ($valueNode->value === 'SerializedValue') {
|
2015-08-17 17:01:55 +03:00
|
|
|
return 'DeserializedValue';
|
|
|
|
}
|
2018-02-09 13:26:22 +03:00
|
|
|
return Utils::undefined();
|
2015-08-17 17:01:55 +03:00
|
|
|
}
|
|
|
|
}
|
2016-10-18 16:25:32 +03:00
|
|
|
|
|
|
|
class Special
|
|
|
|
{
|
|
|
|
public $value;
|
|
|
|
|
|
|
|
public function __construct($value)
|
|
|
|
{
|
|
|
|
$this->value = $value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class NotSpecial
|
|
|
|
{
|
|
|
|
public $value;
|
|
|
|
|
|
|
|
public function __construct($value)
|
|
|
|
{
|
|
|
|
$this->value = $value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class Adder
|
|
|
|
{
|
|
|
|
public $num;
|
|
|
|
|
|
|
|
public $test;
|
|
|
|
|
|
|
|
public function __construct($num)
|
|
|
|
{
|
|
|
|
$this->num = $num;
|
|
|
|
|
2016-10-22 13:18:16 +03:00
|
|
|
$this->test = function($source, $args, $context) {
|
2016-10-18 16:25:32 +03:00
|
|
|
return $this->num + $args['addend1'] + $context['addend2'];
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|