blib/lib/GraphQL/Houtou/Role/Abstract.pm

filter: Statementstmt 33.3% 15 / 45 Branchbran 0.0% 0 / 20 Conditioncond 0.0% 0 / 40 MC/DCmcdc 0.0% 0 / 19 Subroutinesub 62.5% 5 / 8 Podpod n/a totaltotal 15.1% 20 / 132 CC 25 SCAR 54.7
CC
25
Cov
14%
_default_resolve_type
380.0
_ensure_valid_runtime_type
56.0
_complete_value
2.0
CRAP 238.1
↑ Summary blib/lib/GraphQL/Houtou/Runtime/VMCompiler.pm »
1 package GraphQL::Houtou::Role::Abstract;
2  
3 21 ▶use 5.014;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 21 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 21 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 21 ▶use Role::Tiny;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 21 ▶use GraphQL::Houtou::Error ();
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 # Runtime completion helpers for interfaces and unions.
12  
13 0 ▶sub _complete_value {
Subroutine _complete_value: not called CC=1 SCAR=6.9
14 0 my ($self) = @_;
15 0 die "Abstract::_complete_value is part of the removed legacy execution path; use GraphQL::Houtou::Schema->build_runtime or ->build_native_runtime for abstract completion on '@{[$self->name]}'.\n";
16 }
17  
18 0 ▶sub _ensure_valid_runtime_type {
Subroutine _ensure_valid_runtime_type: not called CC=7 SCAR=40.3
19 0 my ($self, $runtime_type_or_name, $context, $nodes, $info, $result) = @_;
20 my $runtime_type = ref($runtime_type_or_name)
21 ? $runtime_type_or_name
22 0 ▶ : $context->{schema}->name2type->{$runtime_type_or_name};
Branch: 1 branch
BranchTrueFalseTotal
ref $runtime_type_or_name ? : 0 0 0
23  
24 0 ▶ die GraphQL::Houtou::Error->new(
Branch: 1 branch
BranchTrueFalseTotal
unless $runtime_type and $runtime_type->isa("GraphQL::Houtou::Type::Object") || $runtime_type->isa("GraphQL::Type::Object") 0 0 0
Condition0%0/6
$runtime_type and $runtime_type->isa("GraphQL::Houtou::Type::Object") || $runtime_type->isa("GraphQL::Type::Object")
!ll&&!rl&&r
000
$runtime_type->isa("GraphQL::Houtou::Type::Object") or $runtime_type->isa("GraphQL::Type::Object")
l!l&&r!l&&!r
000
MC/DC0%0/3
$runtime_type and $runtime_type->isa("GraphQL::Houtou::Type::Object") || $runtime_type->isa("GraphQL::Type::Object")
$runtime_type $runtime_type->isa("GraphQL::Houtou::Type::Object") $runtime_type->isa("GraphQL::Type::Object")
Truth table0%0/4
A and B or C
A= $runtime_typeB= $runtime_type->isa("GraphQL::Houtou::Type::Object")C= $runtime_type->isa("GraphQL::Type::Object")
ABCresult
0XX0
1000
11X1
1011
25 0 message => "Abstract type @{[$self->name]} must resolve to an " .
26 0 "Object type at runtime for field @{[$info->{parent_type}->name]}." .
27 0 ▶ "@{[$info->{field_name}]} with value $result, received '" .
Branch: 1 branch
BranchTrueFalseTotal
$runtime_type ? : 0 0 0
28 ($runtime_type ? $runtime_type->name : 'undef') . "'.",
29 nodes => [ $nodes ],
30 ) if !$runtime_type
31 || !($runtime_type->isa('GraphQL::Houtou::Type::Object')
32 || $runtime_type->isa('GraphQL::Type::Object'));
33  
34 die GraphQL::Houtou::Error->new(
35 0 message => "Runtime Object type '@{[$runtime_type->name]}' is not a possible type for " .
36 0 "'@{[$self->name]}'.",
37 nodes => [ $nodes ],
38 0 ▶ ) if !$context->{schema}->is_possible_type($self, $runtime_type);
Branch: 1 branch
BranchTrueFalseTotal
unless $context->{"schema"}->is_possible_type($self, $runtime_type) 0 0 0
39  
40 0 return $runtime_type;
41 }
42  
43 0 ▶sub _default_resolve_type {
Subroutine _default_resolve_type: not called CC=19 SCAR=59.4
44 0 my ($value, $context, $info, $abstract_type) = @_;
45 0 ▶ my $schema = ($info && $info->{schema}) || $context->{schema};
Condition0%0/6
$info && $info->{'schema'} || $context->{'schema'}
l!l&&r!l&&!r
000
$info and $info->{"schema"}
!ll&&!rl&&r
000
MC/DC0%0/3
$info && $info->{'schema'} || $context->{'schema'}
$info $info->{"schema"} $context->{'schema'}
Truth table0%0/5
A and B || C
A= $infoB= $info->{"schema"}C= $context->{'schema'}
ABCresult
11X1
0X11
1011
0X00
1000
46 0 ▶ my $tag_resolver = $abstract_type->can('tag_resolver') ? $abstract_type->tag_resolver : undef;
Branch: 1 branch
BranchTrueFalseTotal
$abstract_type->can('tag_resolver') ? : 0 0 0
47  
48 0 ▶ if ($tag_resolver) {
Branch: 1 branch
BranchTrueFalseTotal
if ($tag_resolver) 0 0 0
49 0 my $tag = $tag_resolver->($value, $context, $abstract_type);
50 0 ▶ if (defined $tag) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $tag) 0 0 0
51 0 ▶ my $declared_tag_map = $abstract_type->can('tag_map') ? $abstract_type->tag_map : undef;
Branch: 1 branch
BranchTrueFalseTotal
$abstract_type->can('tag_map') ? : 0 0 0
52 return $declared_tag_map->{$tag}
53 0 ▶ if $declared_tag_map && exists $declared_tag_map->{$tag};
Branch: 1 branch
BranchTrueFalseTotal
if $declared_tag_map and exists $declared_tag_map->{$tag} 0 0 0
Condition0%0/3
$declared_tag_map and exists $declared_tag_map->{$tag}
!ll&&!rl&&r
000
MC/DC0%0/2
$declared_tag_map and exists $declared_tag_map->{$tag}
$declared_tag_map exists $declared_tag_map->{$tag}
Truth table0%0/3
A and B
A= $declared_tag_mapB= exists $declared_tag_map->{$tag}
ABresult
0X0
100
111
54  
55 0 ▶ my $runtime_cache = ($info && $info->{runtime_cache}) || $schema->runtime_cache || $schema->prepare_runtime;
Condition0%0/9
$info && $info->{'runtime_cache'} || $schema->runtime_cache || $schema->prepare_runtime
l!l&&r!l&&!r
000
$info and $info->{"runtime_cache"} or $schema->runtime_cache
l!l&&r!l&&!r
000
$info and $info->{"runtime_cache"}
!ll&&!rl&&r
000
MC/DC0%0/4
$info && $info->{'runtime_cache'} || $schema->runtime_cache || $schema->prepare_runtime
$info $info->{"runtime_cache"} $schema->runtime_cache $schema->prepare_runtime
Truth table0%0/7
A and B or C || D
A= $infoB= $info->{"runtime_cache"}C= $schema->runtime_cacheD= $schema->prepare_runtime
ABCDresult
11XX1
0X1X1
101X1
0X011
10011
0X000
10000
56 0 ▶ my $tag_map = ($runtime_cache->{runtime_tag_map} || {})->{ $abstract_type->name } || {};
Condition0%0/4
($runtime_cache->{'runtime_tag_map'} || {})->{$abstract_type->name} || {}
l!l
00
$runtime_cache->{'runtime_tag_map'} || {}
l!l
00
MC/DC0%0/1
($runtime_cache->{'runtime_tag_map'} || {})->{$abstract_type->name} || {}
$runtime_cache->{'runtime_tag_map'}
Truth table0%0/2
A
A= $runtime_cache->{'runtime_tag_map'}
Aresult
11
00
57 0 ▶ return $tag_map->{$tag} if exists $tag_map->{$tag};
Branch: 1 branch
BranchTrueFalseTotal
if exists $tag_map->{$tag} 0 0 0
58 }
59 }
60  
61 0 ▶ my $runtime_cache = ($info && $info->{runtime_cache}) || $schema->runtime_cache || $schema->prepare_runtime;
Condition0%0/9
$info && $info->{'runtime_cache'} || $schema->runtime_cache || $schema->prepare_runtime
l!l&&r!l&&!r
000
$info and $info->{"runtime_cache"} or $schema->runtime_cache
l!l&&r!l&&!r
000
$info and $info->{"runtime_cache"}
!ll&&!rl&&r
000
MC/DC0%0/4
$info && $info->{'runtime_cache'} || $schema->runtime_cache || $schema->prepare_runtime
$info $info->{"runtime_cache"} $schema->runtime_cache $schema->prepare_runtime
Truth table0%0/7
A and B or C || D
A= $infoB= $info->{"runtime_cache"}C= $schema->runtime_cacheD= $schema->prepare_runtime
ABCDresult
11XX1
0X1X1
101X1
0X011
10011
0X000
10000
62 0 ▶ my @possibles = @{ $runtime_cache->{possible_types}{ $abstract_type->name } || $schema->get_possible_types($abstract_type) };
Condition0%0/3
$runtime_cache->{'possible_types'}{$abstract_type->name} || $schema->get_possible_types($abstract_type)
l!l&&r!l&&!r
000
MC/DC0%0/2
$runtime_cache->{'possible_types'}{$abstract_type->name} || $schema->get_possible_types($abstract_type)
$runtime_cache->{'possible_types'}{$abstract_type->name} $schema->get_possible_types($abstract_type)
Truth table0%0/3
A || B
A= $runtime_cache->{'possible_types'}{$abstract_type->name}B= $schema->get_possible_types($abstract_type)
ABresult
1X1
011
000
63 0 return (grep { $_->is_type_of->($value, $context, $info) } grep { $_->is_type_of } @possibles)[0];
64 }
65  
66 21 1;
↑ Summary blib/lib/GraphQL/Houtou/Runtime/VMCompiler.pm »