| 1 | package GraphQL::Type::NonNull; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 18 | ▶ | use 5.014; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 18 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 18 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 18 | ▶ | use Moo; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 18 | ▶ | use Types::Standard -all; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 18 | ▶ | use GraphQL::MaybeTypeCheck; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 18 | extends qw(GraphQL::Type); | |||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | 18 | our $VERSION = '0.02'; | |||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | # A-ha | ||||||||||||||||||||||||||||
| 14 | 18 | my @TAKE_ON_ME = qw( | |||||||||||||||||||||||||||
| 15 | GraphQL::Role::Input | ||||||||||||||||||||||||||||
| 16 | GraphQL::Role::Output | ||||||||||||||||||||||||||||
| 17 | ); | ||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | =head1 NAME | ||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | GraphQL::Type::NonNull - GraphQL type that is a non-null version of another type | ||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | use GraphQL::Type::NonNull; | ||||||||||||||||||||||||||||
| 26 | my $type = GraphQL::Type::NonNull->new(of => $other_type); | ||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | Type that is a wrapper for another type. Means data cannot be a null value. | ||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | =head1 ATTRIBUTES | ||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | =head2 of | ||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | GraphQL type object of which this is a non-null version. | ||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | =cut | ||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | 18 | has of => ( | |||||||||||||||||||||||||||
| 41 | is => 'ro', | ||||||||||||||||||||||||||||
| 42 | isa => InstanceOf['GraphQL::Type'], | ||||||||||||||||||||||||||||
| 43 | required => 1, | ||||||||||||||||||||||||||||
| 44 | handles => [ qw(name) ], | ||||||||||||||||||||||||||||
| 45 | ); | ||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | =head1 METHODS | ||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | =head2 BUILD | ||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | L<Moo> method that applies the relevant roles. | ||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | =cut | ||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | 242 | ▶ | sub BUILD { | ||||||||||||||||||||||||||
|
Subroutine
BUILD: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 56 | 242 | my ($self, $args) = @_; | |||||||||||||||||||||||||||
| 57 | 242 | my $of = $self->of; | |||||||||||||||||||||||||||
| 58 | 242 | Role::Tiny->apply_roles_to_object($self, grep $of->DOES($_), @TAKE_ON_ME); | |||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | =head2 to_string | ||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | Part of serialisation. | ||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | =cut | ||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | 9 | ▶ | has to_string => (is => 'lazy', isa => Str, init_arg => undef, builder => sub { | ||||||||||||||||||||||||||
|
Subroutine
_build_to_string: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 68 | 9 | my ($self) = @_; | |||||||||||||||||||||||||||
| 69 | 9 | $self->of->to_string . '!'; | |||||||||||||||||||||||||||
| 70 | 18 | }); | |||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||
| 72 | =head2 is_valid | ||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | True if given Perl value is a valid value for this type. | ||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||
| 76 | =cut | ||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||
| 78 | 1 | ▶ | method is_valid(Any $item) :ReturnType(Bool) { | ||||||||||||||||||||||||||
|
Subroutine
is_valid: called CC=5 SCAR=17.3
Pod
documented
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 79 | 1 | ▶ | return if !defined $item or !$self->of->is_valid($item); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $item and $self->of->is_valid($item)
MC/DC0%0/2
defined $item and $self->of->is_valid($item)
defined $item
$self->of->is_valid($item)
Truth table33%1/3
A and B
A= defined $itemB= $self->of->is_valid($item)
| |||||||||||||||||||||||||||||
| 80 | 1 | 1; | |||||||||||||||||||||||||||
| 81 | 18 | ▶ | } | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||
| 83 | 75 | ▶ | method graphql_to_perl(Any $item) :ReturnType(Any) { | ||||||||||||||||||||||||||
|
Subroutine
graphql_to_perl: called CC=4 SCAR=14.0
Pod
documented
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 84 | 75 | my $of = $self->of; | |||||||||||||||||||||||||||
| 85 | 75 | ▶ | $of->graphql_to_perl($item) // die $self->to_string . " given null value.\n"; | ||||||||||||||||||||||||||
|
Condition100%2/2
$of->graphql_to_perl($item) // die($self->to_string . " given null value.\n")
MC/DC100%1/1
$of->graphql_to_perl($item) // die($self->to_string . " given null value.\n")
$of->graphql_to_perl($item)
Truth table100%2/2
A
A= $of->graphql_to_perl($item)
| |||||||||||||||||||||||||||||
| 86 | 18 | ▶ | } | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||
| 88 | =head2 name | ||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||
| 90 | The C<name> of the type this object is a non-null version of. | ||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||
| 92 | =cut | ||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||
| 94 | 18 | __PACKAGE__->meta->make_immutable(); | |||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||
| 96 | 18 | 1; | |||||||||||||||||||||||||||