mirror of
https://github.com/retailcrm/graphql-php.git
synced 2024-11-22 04:46:04 +03:00
Add NullableType interface
This commit is contained in:
parent
e22b400373
commit
9a0dbff26b
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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)
|
||||
{
|
||||
|
20
src/Type/Definition/NullableType.php
Normal file
20
src/Type/Definition/NullableType.php
Normal 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
|
||||
{
|
||||
}
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
*/
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user