Merge pull request #416 from erikgaal/master

Add NullableType interface
This commit is contained in:
Vladimir Razuvaev 2018-12-07 18:26:04 +07:00 committed by GitHub
commit f96bd2740d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 33 additions and 19 deletions

View File

@ -22,7 +22,7 @@ use function sprintf;
/**
* Class EnumType
*/
class EnumType extends Type implements InputType, OutputType, LeafType, NamedType
class EnumType extends Type implements InputType, OutputType, LeafType, NullableType, NamedType
{
/** @var EnumTypeDefinitionNode|null */
public $astNode;

View File

@ -18,7 +18,7 @@ use function sprintf;
/**
* Class InputObjectType
*/
class InputObjectType extends Type implements InputType, NamedType
class InputObjectType extends Type implements InputType, NullableType, NamedType
{
/** @var InputObjectTypeDefinitionNode|null */
public $astNode;

View File

@ -15,7 +15,7 @@ use function sprintf;
/**
* Class InterfaceType
*/
class InterfaceType extends Type implements AbstractType, OutputType, CompositeType, NamedType
class InterfaceType extends Type implements AbstractType, OutputType, CompositeType, NullableType, NamedType
{
/** @var InterfaceTypeDefinitionNode|null */
public $astNode;

View File

@ -7,7 +7,7 @@ namespace GraphQL\Type\Definition;
/**
* Class ListOfType
*/
class ListOfType extends Type implements WrappingType, OutputType, InputType
class ListOfType extends Type implements WrappingType, OutputType, NullableType, InputType
{
/** @var ObjectType|InterfaceType|UnionType|ScalarType|InputObjectType|EnumType */
public $ofType;

View File

@ -4,8 +4,6 @@ declare(strict_types=1);
namespace GraphQL\Type\Definition;
use Exception;
use GraphQL\Error\InvariantViolation;
use GraphQL\Utils\Utils;
/**
@ -13,13 +11,11 @@ use GraphQL\Utils\Utils;
*/
class NonNull extends Type implements WrappingType, OutputType, InputType
{
/** @var ObjectType|InterfaceType|UnionType|ScalarType|InputObjectType|EnumType|ListOfType */
/** @var NullableType */
private $ofType;
/**
* @param callable|Type $type
*
* @throws Exception
* @param NullableType $type
*/
public function __construct($type)
{
@ -29,7 +25,7 @@ class NonNull extends Type implements WrappingType, OutputType, InputType
/**
* @param mixed $type
*
* @return ObjectType|InterfaceType|UnionType|ScalarType|InputObjectType|EnumType|ListOfType
* @return NullableType
*/
public static function assertNullableType($type)
{
@ -67,9 +63,7 @@ class NonNull extends Type implements WrappingType, OutputType, InputType
/**
* @param bool $recurse
*
* @return ObjectType|InterfaceType|UnionType|ScalarType|InputObjectType|EnumType|ListOfType
*
* @throws InvariantViolation
* @return Type
*/
public function getWrappedType($recurse = false)
{

View File

@ -0,0 +1,20 @@
<?php
declare(strict_types=1);
namespace GraphQL\Type\Definition;
/*
export type GraphQLNullableType =
| GraphQLScalarType
| GraphQLObjectType
| GraphQLInterfaceType
| GraphQLUnionType
| GraphQLEnumType
| GraphQLInputObjectType
| GraphQLList<any>;
*/
interface NullableType
{
}

View File

@ -54,7 +54,7 @@ use function sprintf;
* }
* ]);
*/
class ObjectType extends Type implements OutputType, CompositeType, NamedType
class ObjectType extends Type implements OutputType, CompositeType, NullableType, NamedType
{
/** @var ObjectTypeDefinitionNode|null */
public $astNode;

View File

@ -27,7 +27,7 @@ use function is_string;
* }
* }
*/
abstract class ScalarType extends Type implements OutputType, InputType, LeafType, NamedType
abstract class ScalarType extends Type implements OutputType, InputType, LeafType, NullableType, NamedType
{
/** @var ScalarTypeDefinitionNode|null */
public $astNode;

View File

@ -137,7 +137,7 @@ abstract class Type implements JsonSerializable
}
/**
* @param ObjectType|InterfaceType|UnionType|ScalarType|InputObjectType|EnumType|ListOfType $wrappedType
* @param NullableType $wrappedType
*
* @return NonNull
*
@ -338,7 +338,7 @@ abstract class Type implements JsonSerializable
/**
* @param Type $type
*
* @return ObjectType|InterfaceType|UnionType|ScalarType|InputObjectType|EnumType|ListOfType
* @return NullableType
*
* @api
*/

View File

@ -17,7 +17,7 @@ use function sprintf;
/**
* Class UnionType
*/
class UnionType extends Type implements AbstractType, OutputType, CompositeType, NamedType
class UnionType extends Type implements AbstractType, OutputType, CompositeType, NullableType, NamedType
{
/** @var UnionTypeDefinitionNode */
public $astNode;