mirror of
https://github.com/retailcrm/graphql-php.git
synced 2024-11-22 12:56:05 +03:00
Merge pull request #416 from erikgaal/master
Add NullableType interface
This commit is contained in:
commit
f96bd2740d
@ -22,7 +22,7 @@ use function sprintf;
|
|||||||
/**
|
/**
|
||||||
* Class EnumType
|
* Class EnumType
|
||||||
*/
|
*/
|
||||||
class EnumType extends Type implements InputType, OutputType, LeafType, NamedType
|
class EnumType extends Type implements InputType, OutputType, LeafType, NullableType, NamedType
|
||||||
{
|
{
|
||||||
/** @var EnumTypeDefinitionNode|null */
|
/** @var EnumTypeDefinitionNode|null */
|
||||||
public $astNode;
|
public $astNode;
|
||||||
|
@ -18,7 +18,7 @@ use function sprintf;
|
|||||||
/**
|
/**
|
||||||
* Class InputObjectType
|
* Class InputObjectType
|
||||||
*/
|
*/
|
||||||
class InputObjectType extends Type implements InputType, NamedType
|
class InputObjectType extends Type implements InputType, NullableType, NamedType
|
||||||
{
|
{
|
||||||
/** @var InputObjectTypeDefinitionNode|null */
|
/** @var InputObjectTypeDefinitionNode|null */
|
||||||
public $astNode;
|
public $astNode;
|
||||||
|
@ -15,7 +15,7 @@ use function sprintf;
|
|||||||
/**
|
/**
|
||||||
* Class InterfaceType
|
* Class InterfaceType
|
||||||
*/
|
*/
|
||||||
class InterfaceType extends Type implements AbstractType, OutputType, CompositeType, NamedType
|
class InterfaceType extends Type implements AbstractType, OutputType, CompositeType, NullableType, NamedType
|
||||||
{
|
{
|
||||||
/** @var InterfaceTypeDefinitionNode|null */
|
/** @var InterfaceTypeDefinitionNode|null */
|
||||||
public $astNode;
|
public $astNode;
|
||||||
|
@ -7,7 +7,7 @@ namespace GraphQL\Type\Definition;
|
|||||||
/**
|
/**
|
||||||
* Class ListOfType
|
* 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 */
|
/** @var ObjectType|InterfaceType|UnionType|ScalarType|InputObjectType|EnumType */
|
||||||
public $ofType;
|
public $ofType;
|
||||||
|
@ -4,8 +4,6 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace GraphQL\Type\Definition;
|
namespace GraphQL\Type\Definition;
|
||||||
|
|
||||||
use Exception;
|
|
||||||
use GraphQL\Error\InvariantViolation;
|
|
||||||
use GraphQL\Utils\Utils;
|
use GraphQL\Utils\Utils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -13,13 +11,11 @@ use GraphQL\Utils\Utils;
|
|||||||
*/
|
*/
|
||||||
class NonNull extends Type implements WrappingType, OutputType, InputType
|
class NonNull extends Type implements WrappingType, OutputType, InputType
|
||||||
{
|
{
|
||||||
/** @var ObjectType|InterfaceType|UnionType|ScalarType|InputObjectType|EnumType|ListOfType */
|
/** @var NullableType */
|
||||||
private $ofType;
|
private $ofType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param callable|Type $type
|
* @param NullableType $type
|
||||||
*
|
|
||||||
* @throws Exception
|
|
||||||
*/
|
*/
|
||||||
public function __construct($type)
|
public function __construct($type)
|
||||||
{
|
{
|
||||||
@ -29,7 +25,7 @@ class NonNull extends Type implements WrappingType, OutputType, InputType
|
|||||||
/**
|
/**
|
||||||
* @param mixed $type
|
* @param mixed $type
|
||||||
*
|
*
|
||||||
* @return ObjectType|InterfaceType|UnionType|ScalarType|InputObjectType|EnumType|ListOfType
|
* @return NullableType
|
||||||
*/
|
*/
|
||||||
public static function assertNullableType($type)
|
public static function assertNullableType($type)
|
||||||
{
|
{
|
||||||
@ -67,9 +63,7 @@ class NonNull extends Type implements WrappingType, OutputType, InputType
|
|||||||
/**
|
/**
|
||||||
* @param bool $recurse
|
* @param bool $recurse
|
||||||
*
|
*
|
||||||
* @return ObjectType|InterfaceType|UnionType|ScalarType|InputObjectType|EnumType|ListOfType
|
* @return Type
|
||||||
*
|
|
||||||
* @throws InvariantViolation
|
|
||||||
*/
|
*/
|
||||||
public function getWrappedType($recurse = false)
|
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 */
|
/** @var ObjectTypeDefinitionNode|null */
|
||||||
public $astNode;
|
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 */
|
/** @var ScalarTypeDefinitionNode|null */
|
||||||
public $astNode;
|
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
|
* @return NonNull
|
||||||
*
|
*
|
||||||
@ -338,7 +338,7 @@ abstract class Type implements JsonSerializable
|
|||||||
/**
|
/**
|
||||||
* @param Type $type
|
* @param Type $type
|
||||||
*
|
*
|
||||||
* @return ObjectType|InterfaceType|UnionType|ScalarType|InputObjectType|EnumType|ListOfType
|
* @return NullableType
|
||||||
*
|
*
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
|
@ -17,7 +17,7 @@ use function sprintf;
|
|||||||
/**
|
/**
|
||||||
* Class UnionType
|
* Class UnionType
|
||||||
*/
|
*/
|
||||||
class UnionType extends Type implements AbstractType, OutputType, CompositeType, NamedType
|
class UnionType extends Type implements AbstractType, OutputType, CompositeType, NullableType, NamedType
|
||||||
{
|
{
|
||||||
/** @var UnionTypeDefinitionNode */
|
/** @var UnionTypeDefinitionNode */
|
||||||
public $astNode;
|
public $astNode;
|
||||||
|
Loading…
Reference in New Issue
Block a user