blib/lib/GraphQL/Houtou/Schema.pm

filter: Statementstmt 94.8% 863 / 910 Branchbran 80.5% 372 / 462 Conditioncond 60.5% 267 / 441 MC/DCmcdc 33.6% 82 / 244 Subroutinesub 95.7% 91 / 95 Podpod 14.8% 7 / 47 totaltotal 76.4% 1682 / 2199 CC 462 SCAR 34.9
CC
462
Cov
83%
validation_errors
124.0
_is_builtin_scalar_pair
90.0
_build_runtime_tag_map
50.1
CRAP 32.7
« blib/lib/GraphQL/Houtou/Type/Interface.pm ↑ Summary blib/lib/GraphQL/Houtou/Runtime/VMBlock.pm »
1 package GraphQL::Houtou::Schema;
2  
3 62 ▶use 5.014;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 62 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 62 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 62 ▶use Exporter 'import';
Subroutine BEGIN: called CC=1 SCAR=0.0
8 62 ▶use JSON::MaybeXS ();
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 62 ▶use GraphQL::Houtou::Directive ();
Subroutine BEGIN: called CC=1 SCAR=0.0
11 62 ▶use GraphQL::Houtou::Runtime::SchemaGraph ();
Subroutine BEGIN: called CC=1 SCAR=0.0
12 62 ▶use GraphQL::Houtou::Type::Scalar qw($Int $Float $String $Boolean $ID);
Subroutine BEGIN: called CC=1 SCAR=0.0
13 62 ▶use GraphQL::Houtou::Introspection qw($SCHEMA_META_TYPE);
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 62 our @EXPORT_OK = qw(lookup_type);
16 62 my $JSON = JSON::MaybeXS->new->canonical;
17  
18 249 ▶sub new {
Subroutine new: called CC=4 SCAR=13.9
Pod documented
19 249 my ($class, %args) = @_;
20 249 ▶ die "GraphQL::Houtou::Schema requires query" if !defined $args{query};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $args{"query"} 0 249 249
21 my $self = bless {
22 query => $args{query},
23 mutation => $args{mutation},
24 subscription => $args{subscription},
25 description => $args{description},
26 types => $args{types} || [ $Int, $Float, $String, $Boolean, $ID ],
27 249 ▶ directives => $args{directives} || \@GraphQL::Houtou::Directive::SPECIFIED_DIRECTIVES,
Condition100%4/4
$args{'types'} || [$GraphQL::Houtou::Schema::Int, $GraphQL::Houtou::Schema::Float, $GraphQL::Houtou::Schema::String, $GraphQL::Houtou::Schema::Boolean, $GraphQL::Houtou::Schema::ID]
l!l
96153
$args{'directives'} || \@GraphQL::Houtou::Directive::SPECIFIED_DIRECTIVES
l!l
31218
MC/DC100%1/1
$args{'types'} || [$GraphQL::Houtou::Schema::Int, $GraphQL::Houtou::Schema::Float, $GraphQL::Houtou::Schema::String, $GraphQL::Houtou::Schema::Boolean, $GraphQL::Houtou::Schema::ID]
$args{'types'}
MC/DC100%1/1
$args{'directives'} || \@GraphQL::Houtou::Directive::SPECIFIED_DIRECTIVES
$args{'directives'}
Truth table100%2/2
A
A= $args{'types'}
Aresult
11
00
Truth table100%2/2
A
A= $args{'directives'}
Aresult
11
00
28 }, $class;
29 249 return $self;
30 }
31  
32 16 ▶sub description { return $_[0]->{description} }
Subroutine description: called CC=1 SCAR=0.0
Pod undocumented
33 1460 ▶sub query { return $_[0]->{query} }
Subroutine query: called CC=1 SCAR=0.0
Pod undocumented
34 1431 ▶sub mutation { return $_[0]->{mutation} }
Subroutine mutation: called CC=1 SCAR=0.0
Pod undocumented
35 1426 ▶sub subscription { return $_[0]->{subscription} }
Subroutine subscription: called CC=1 SCAR=0.0
Pod undocumented
36 249 ▶sub types { return $_[0]->{types} }
Subroutine types: called CC=1 SCAR=0.0
Pod undocumented
37 1360 ▶sub directives { return $_[0]->{directives} }
Subroutine directives: called CC=1 SCAR=0.0
Pod undocumented
38  
39 62 our %KIND2CLASS = (
40 type => 'GraphQL::Houtou::Type::Object',
41 interface => 'GraphQL::Houtou::Type::Interface',
42 union => 'GraphQL::Houtou::Type::Union',
43 enum => 'GraphQL::Houtou::Type::Enum',
44 input => 'GraphQL::Houtou::Type::InputObject',
45 scalar => 'GraphQL::Houtou::Type::Scalar',
46 );
47 62 my @ROOT_ATTRS = qw(query mutation subscription);
48 62 my %VALID_DIRECTIVE_LOCATION = map { ($_ => 1) } qw(
49 QUERY MUTATION SUBSCRIPTION FIELD FRAGMENT_DEFINITION FRAGMENT_SPREAD
50 INLINE_FRAGMENT VARIABLE_DEFINITION SCHEMA SCALAR OBJECT FIELD_DEFINITION
51 ARGUMENT_DEFINITION INTERFACE UNION ENUM ENUM_VALUE INPUT_OBJECT
52 INPUT_FIELD_DEFINITION
53 );
54  
55 59 ▶sub from_doc {
Subroutine from_doc: called CC=2 SCAR=6.9
Pod documented
56 59 my ($class, $doc, %opts) = @_;
57 59 require GraphQL::Houtou;
58 59 require GraphQL::Houtou::XS::Parser;
59 my ($ast, $diagnostics) = @{
60 59 GraphQL::Houtou::XS::Parser::_parse_with_diagnostics_xs($doc)
61 };
62 58 ▶ if (@$diagnostics) {
Branch: 1 branch
BranchTrueFalseTotal
if (@$diagnostics) 4 54 58
63 4 die join("\n", map { $_->{message} } @$diagnostics) . "\n";
64 }
65 54 return $class->from_ast($ast, %opts);
66 }
67  
68 54 ▶sub from_ast {
Subroutine from_ast: called CC=20 SCAR=30.1
Pod documented
69 54 my ($class, $ast, %opts) = @_;
70 54 ▶ my $kind2class = $opts{kind2class} || \%KIND2CLASS;
Condition50%1/2
$opts{'kind2class'} || \%GraphQL::Houtou::Schema::KIND2CLASS
l!l
054
MC/DC0%0/1
$opts{'kind2class'} || \%GraphQL::Houtou::Schema::KIND2CLASS
$opts{'kind2class'}
Truth table50%1/2
A
A= $opts{'kind2class'}
Aresult
11
00
71  
72 54 my ($merged_ast, $merge_error) = eval { (_merge_type_system_extensions($ast, $kind2class), undef) };
73 54 ▶ $merge_error = $@ if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 4 50 54
74 54 ▶ die $merge_error if $merge_error;
Branch: 1 branch
BranchTrueFalseTotal
if $merge_error 4 50 54
75  
76 50 ▶ my @type_nodes = grep { $kind2class->{$_->{kind} || q()} } @$merged_ast;
Condition50%1/2
$_->{'kind'} || ''
l!l
3730
MC/DC0%0/1
$_->{'kind'} || ''
$_->{'kind'}
Truth table50%1/2
A
A= $_->{'kind'}
Aresult
11
00
77 50 ▶ my ($schema_node, $extra_schema_node) = grep { ($_->{kind} || q()) eq 'schema' } @$merged_ast;
Condition50%1/2
$_->{'kind'} || ''
l!l
3730
MC/DC0%0/1
$_->{'kind'} || ''
$_->{'kind'}
Truth table50%1/2
A
A= $_->{'kind'}
Aresult
11
00
78 50 ▶ die "Must provide only one schema definition.\n" if $extra_schema_node;
Branch: 1 branch
BranchTrueFalseTotal
if $extra_schema_node 1 49 50
79  
80 49 my %name2type;
81 49 for my $node (@type_nodes) {
82 die "Type '$node->{name}' was defined more than once.\n"
83 229 ▶ if $name2type{ $node->{name} };
Branch: 1 branch
BranchTrueFalseTotal
if $name2type{$node->{"name"}} 1 228 229
84 228 my $type_class = $kind2class->{ $node->{kind} };
85 228 (my $module_file = $type_class) =~ s{::}{/}g;
86 228 require "$module_file.pm";
87 228 $name2type{ $node->{name} } = $type_class->from_ast(\%name2type, $node);
88 }
89 48 for my $builtin ($Int, $Float, $String, $Boolean, $ID) {
90 240 ▶ $name2type{ $builtin->name } ||= $builtin;
Condition33%1/3
$name2type{$builtin->name} ||= $builtin
l!l&&r!l&&!r
02400
MC/DC0%0/2
$name2type{$builtin->name} ||= $builtin
$name2type{$builtin->name} $builtin
Truth table33%1/3
A ||= B
A= $name2type{$builtin->name}B= $builtin
ABresult
1X1
011
000
91 }
92  
93 48 ▶ if (!$schema_node) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($schema_node) 39 9 48
94 $schema_node = +{
95 39 ▶ map { $name2type{ ucfirst $_ } ? ($_ => ucfirst $_) : () } @ROOT_ATTRS
Branch: 1 branch
BranchTrueFalseTotal
$name2type{ucfirst $_} ? : 39 78 117
96 };
97 }
98 die "Must provide schema definition with query type or a type named Query.\n"
99 48 ▶ if !$schema_node->{query};
Branch: 1 branch
BranchTrueFalseTotal
unless $schema_node->{"query"} 1 47 48
100  
101 132 my @directives = map { GraphQL::Houtou::Directive->from_ast(\%name2type, $_) }
102 47 ▶ grep { ($_->{kind} || q()) eq 'directive' } @$merged_ast;
Condition50%1/2
$_->{'kind'} || ''
l!l
3670
MC/DC0%0/1
$_->{'kind'} || ''
$_->{'kind'}
Truth table50%1/2
A
A= $_->{'kind'}
Aresult
11
00
103 47 my @all_directives = (@GraphQL::Houtou::Directive::SPECIFIED_DIRECTIVES, @directives);
104 47 my $ast_validation_errors = _type_system_directive_errors(
105 $merged_ast, \@all_directives,
106 );
107  
108 my $schema = $class->new(
109 (map {
110 $schema_node->{$_}
111 139 ▶ ? ($_ => $name2type{ $schema_node->{$_} }
Branch: 3 branches
BranchTrueFalseTotal
$schema_node->{$_} ? : 51 88 139
$schema_node->{'description'} ? : 1 45 46
@directives ? : 24 22 46
Condition100%2/2
$name2type{$schema_node->{$_}} // die("Specified $_ type '$schema_node->{$_}' not found.\n")
l!l
501
MC/DC100%1/1
$name2type{$schema_node->{$_}} // die("Specified $_ type '$schema_node->{$_}' not found.\n")
$name2type{$schema_node->{$_}}
Truth table100%2/2
A
A= $name2type{$schema_node->{$_}}
Aresult
11
00
112 // die "Specified $_ type '$schema_node->{$_}' not found.\n")
113 : ()
114 } @ROOT_ATTRS),
115 47 ($schema_node->{description} ? (description => $schema_node->{description}) : ()),
116 (@directives
117 ? (directives => \@all_directives)
118 : ()),
119 types => [ values %name2type ],
120 );
121 46 $schema->{_ast_validation_errors} = $ast_validation_errors;
122 46 ▶ $schema->_apply_resolvers($opts{resolvers}) if $opts{resolvers};
Branch: 1 branch
BranchTrueFalseTotal
if $opts{"resolvers"} 20 26 46
123 44 $schema->name2type;
124 43 return $schema;
125 }
126  
127 54 ▶sub _merge_type_system_extensions {
Subroutine _merge_type_system_extensions: called CC=21 SCAR=30.5
128 54 my ($ast, $kind2class) = @_;
129 54 my @result;
130 my %definitions;
131 54 my @extensions;
132 54 my $schema_definition;
133 54 my %repeatable = map { ($_ => 0) } qw(include skip deprecated specifiedBy oneOf);
134  
135 54 for my $node (@$ast) {
136 396 ▶ if (!$node->{extension}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($node->{"extension"}) 373 23 396
137 373 push @result, $node;
138 373 ▶ if ($kind2class->{ $node->{kind} || q() }) {
Branch: 2 branches
BranchTrueFalseTotal
if ($$kind2class{$node->{'kind'} or ''}) { } 234 139 373
elsif (($node->{'kind'} || '') eq 'schema' and not $schema_definition) { } 5 267 272
Condition50%1/2
$node->{'kind'} || ''
l!l
3730
MC/DC0%0/1
$node->{'kind'} || ''
$node->{'kind'}
Truth table50%1/2
A
A= $node->{'kind'}
Aresult
11
00
139 $definitions{ $node->{name} } = $node
140 234 ▶ if !exists $definitions{ $node->{name} };
Branch: 1 branch
BranchTrueFalseTotal
unless exists $definitions{$node->{"name"}} 233 1 234
141 ▶ } elsif (($node->{kind} || q()) eq 'schema' && !$schema_definition) {
Condition80%4/5
($node->{"kind"} || "") eq "schema" and not $schema_definition
!ll&&!rl&&r
13315
$node->{'kind'} || ''
l!l
1390
MC/DC50%1/2
($node->{"kind"} || "") eq "schema" and not $schema_definition
$node->{'kind'} not $schema_definition
Truth table66%2/3
A and not(B)
A= $node->{'kind'}B= not $schema_definition
ABresult
0X0
100
111
142 5 $schema_definition = $node;
143 }
144 373 next;
145 }
146 23 push @extensions, $node;
147 }
148 54 for my $node (@$ast) {
149 396 ▶ next if ($node->{kind} || q()) ne 'directive';
Branch: 1 branch
BranchTrueFalseTotal
if ($node->{"kind"} || "") ne "directive" 263 133 396
Condition50%1/2
$node->{'kind'} || ''
l!l
3960
MC/DC0%0/1
$node->{'kind'} || ''
$node->{'kind'}
Truth table50%1/2
A
A= $node->{'kind'}
Aresult
11
00
150 133 ▶ $repeatable{ $node->{name} } = $node->{repeatable} ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$node->{'repeatable'} ? : 49 84 133
151 }
152 54 ▶ return \@result if !@extensions;
Branch: 1 branch
BranchTrueFalseTotal
unless @extensions 40 14 54
153  
154 # Copy only nodes that receive extensions. This keeps from_ast from
155 # modifying a caller-owned parser AST while avoiding a full deep clone.
156 14 my %copies;
157 14 for my $extension (@extensions) {
158 23 ▶ my $kind = $extension->{kind} || q();
Condition50%1/2
$extension->{'kind'} || ''
l!l
230
MC/DC0%0/1
$extension->{'kind'} || ''
$extension->{'kind'}
Truth table50%1/2
A
A= $extension->{'kind'}
Aresult
11
00
159 23 ▶ if ($kind eq 'schema') {
Branch: 1 branch
BranchTrueFalseTotal
if ($kind eq "schema") 5 18 23
160 5 ▶ if (!$schema_definition) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($schema_definition) 5 0 5
161 $schema_definition = {
162 kind => 'schema',
163 5 ▶ map { $definitions{ ucfirst $_ } ? ($_ => ucfirst $_) : () } @ROOT_ATTRS
Branch: 1 branch
BranchTrueFalseTotal
$definitions{ucfirst $_} ? : 5 10 15
164 };
165 5 push @result, $schema_definition;
166 }
167 5 $schema_definition = _extension_target_copy(
168 \@result, $schema_definition, \%copies,
169 );
170 5 _merge_schema_extension($schema_definition, $extension, \%repeatable);
171 5 next;
172 }
173  
174 18 my $name = $extension->{name};
175 18 ▶ my $target = $definitions{$name}
Condition100%2/2
$definitions{$name} // die("Cannot extend type '${name}' because it is not defined.\n")
l!l
171
MC/DC100%1/1
$definitions{$name} // die("Cannot extend type '${name}' because it is not defined.\n")
$definitions{$name}
Truth table100%2/2
A
A= $definitions{$name}
Aresult
11
00
176 // die "Cannot extend type '$name' because it is not defined.\n";
177 die "Cannot extend type '$name' as $kind because it is a '$target->{kind}' type.\n"
178 17 ▶ if ($target->{kind} ne $kind);
Branch: 1 branch
BranchTrueFalseTotal
if $target->{"kind"} ne $kind 1 16 17
179 16 $target = _extension_target_copy(\@result, $target, \%copies);
180 16 $definitions{$name} = $target;
181 16 _merge_type_extension($target, $extension, \%repeatable);
182 }
183 10 return \@result;
184 }
185  
186 47 ▶sub _type_system_directive_errors {
Subroutine _type_system_directive_errors: called CC=26 SCAR=33.3
187 47 my ($ast, $directives) = @_;
188 47 my (@errors, %name2directive, %definition_count);
189 47 for my $directive (@$directives) {
190 367 my $name = $directive->name;
191 push @errors, "Directive '\@$name' is defined more than once."
192 367 ▶ if $definition_count{$name}++;
Branch: 1 branch
BranchTrueFalseTotal
if $definition_count{$name}++ 0 367 367
193 367 ▶ $name2directive{$name} ||= $directive;
Condition33%1/3
$name2directive{$name} ||= $directive
l!l&&r!l&&!r
03670
MC/DC0%0/2
$name2directive{$name} ||= $directive
$name2directive{$name} $directive
Truth table33%1/3
A ||= B
A= $name2directive{$name}B= $directive
ABresult
1X1
011
000
194 }
195  
196 47 for my $node (@$ast) {
197 367 ▶ my $kind = $node->{kind} || q();
Condition50%1/2
$node->{'kind'} || ''
l!l
3670
MC/DC0%0/1
$node->{'kind'} || ''
$node->{'kind'}
Truth table50%1/2
A
A= $node->{'kind'}
Aresult
11
00
198 367 ▶ if ($kind eq 'directive') {
Branch: 1 branch
BranchTrueFalseTotal
if ($kind eq "directive") 132 235 367
199 132 my %seen_location;
200 132 ▶ for my $location (@{ $node->{locations} || [] }) {
Condition50%1/2
$node->{'locations'} || []
l!l
1320
MC/DC0%0/1
$node->{'locations'} || []
$node->{'locations'}
Truth table50%1/2
A
A= $node->{'locations'}
Aresult
11
00
201 push @errors, "Directive '\@$node->{name}' has unknown location '$location'."
202 384 ▶ if !$VALID_DIRECTIVE_LOCATION{$location};
Branch: 1 branch
BranchTrueFalseTotal
unless $VALID_DIRECTIVE_LOCATION{$location} 1 383 384
203 push @errors, "Directive '\@$node->{name}' repeats location '$location'."
204 384 ▶ if $seen_location{$location}++;
Branch: 1 branch
BranchTrueFalseTotal
if $seen_location{$location}++ 1 383 384
205 }
206 132 next;
207 }
208 235 my %location = (
209 schema => 'SCHEMA', scalar => 'SCALAR', type => 'OBJECT',
210 interface => 'INTERFACE', union => 'UNION', enum => 'ENUM',
211 input => 'INPUT_OBJECT',
212 );
213 push @errors, _applied_directive_errors(
214 $node->{directives}, $location{$kind},
215 226 ▶ $kind eq 'schema' ? 'schema' : "$kind @{[$node->{name} || q()]}",
Condition50%1/2
$node->{'name'} || ''
l!l
2260
MC/DC0%0/1
$node->{'name'} || ''
$node->{'name'}
Truth table50%1/2
A
A= $node->{'name'}
Aresult
11
00
216 \%name2directive,
217 235 ▶ ) if $location{$kind};
Branch: 2 branches
BranchTrueFalseTotal
if $location{$kind} 235 0 235
$kind eq 'schema' ? : 9 226 235
218  
219 235 ▶ if ($kind eq 'type' || $kind eq 'interface') {
Branch: 3 branches
BranchTrueFalseTotal
if ($kind eq 'type' or $kind eq 'interface') { } 136 99 235
elsif ($kind eq 'input') { } 16 83 99
elsif ($kind eq 'enum') { } 13 70 83
Condition100%3/3
$kind eq "type" or $kind eq "interface"
l!l&&r!l&&!r
1251199
MC/DC100%2/2
$kind eq "type" or $kind eq "interface"
$kind eq "type" $kind eq "interface"
Truth table100%3/3
A or B
A= $kind eq "type"B= $kind eq "interface"
ABresult
1X1
011
000
220 136 ▶ for my $field_name (sort keys %{ $node->{fields} || {} }) {
Condition50%1/2
$node->{'fields'} || {}
l!l
1360
MC/DC0%0/1
$node->{'fields'} || {}
$node->{'fields'}
Truth table50%1/2
A
A= $node->{'fields'}
Aresult
11
00
221 383 my $field = $node->{fields}{$field_name};
222 push @errors, _applied_directive_errors(
223 383 $field->{directives}, 'FIELD_DEFINITION',
224 "$kind $node->{name}.$field_name", \%name2directive,
225 );
226 383 ▶ for my $arg_name (sort keys %{ $field->{args} || {} }) {
Condition100%2/2
$field->{'args'} || {}
l!l
56327
MC/DC100%1/1
$field->{'args'} || {}
$field->{'args'}
Truth table100%2/2
A
A= $field->{'args'}
Aresult
11
00
227 push @errors, _applied_directive_errors(
228 131 $field->{args}{$arg_name}{directives}, 'ARGUMENT_DEFINITION',
229 "$kind $node->{name}.$field_name($arg_name:)", \%name2directive,
230 );
231 }
232 }
233 }
234 elsif ($kind eq 'input') {
235 16 ▶ for my $field_name (sort keys %{ $node->{fields} || {} }) {
Condition50%1/2
$node->{'fields'} || {}
l!l
160
MC/DC0%0/1
$node->{'fields'} || {}
$node->{'fields'}
Truth table50%1/2
A
A= $node->{'fields'}
Aresult
11
00
236 push @errors, _applied_directive_errors(
237 31 $node->{fields}{$field_name}{directives}, 'INPUT_FIELD_DEFINITION',
238 "input $node->{name}.$field_name", \%name2directive,
239 );
240 }
241 }
242 elsif ($kind eq 'enum') {
243 13 ▶ for my $value_name (sort keys %{ $node->{values} || {} }) {
Condition50%1/2
$node->{'values'} || {}
l!l
130
MC/DC0%0/1
$node->{'values'} || {}
$node->{'values'}
Truth table50%1/2
A
A= $node->{'values'}
Aresult
11
00
244 push @errors, _applied_directive_errors(
245 26 $node->{values}{$value_name}{directives}, 'ENUM_VALUE',
246 "enum $node->{name}.$value_name", \%name2directive,
247 );
248 }
249 }
250 }
251 47 return \@errors;
252 }
253  
254 806 ▶sub _applied_directive_errors {
Subroutine _applied_directive_errors: called CC=21 SCAR=30.6
255 806 my ($applications, $location, $coordinate, $name2directive) = @_;
256 806 my (@errors, %seen);
257 806 ▶ for my $application (@{ $applications || [] }) {
Condition100%2/2
$applications || []
l!l
56750
MC/DC100%1/1
$applications || []
$applications
Truth table100%2/2
A
A= $applications
Aresult
11
00
258 60 ▶ my $name = $application->{name} || q();
Condition50%1/2
$application->{'name'} || ''
l!l
600
MC/DC0%0/1
$application->{'name'} || ''
$application->{'name'}
Truth table50%1/2
A
A= $application->{'name'}
Aresult
11
00
259 60 my $directive = $name2directive->{$name};
260 60 ▶ if (!$directive) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($directive) 1 59 60
261 1 push @errors, "Unknown directive '\@$name' on $coordinate.";
262 1 next;
263 }
264 push @errors, "Directive '\@$name' is not repeatable and cannot be used more than once on $coordinate."
265 59 ▶ if $seen{$name}++ && !$directive->repeatable;
Branch: 1 branch
BranchTrueFalseTotal
if $seen{$name}++ and not $directive->repeatable 1 58 59
Condition100%3/3
$seen{$name}++ and not $directive->repeatable
!ll&&!rl&&r
5621
MC/DC100%2/2
$seen{$name}++ and not $directive->repeatable
$seen{$name}++ not $directive->repeatable
Truth table100%3/3
A and not(B)
A= $seen{$name}++B= not $directive->repeatable
ABresult
0X0
100
111
266 push @errors, "Directive '\@$name' cannot be used at $location on $coordinate."
267 59 ▶ if !grep { $_ eq $location } @{ $directive->locations || [] };
Branch: 1 branch
BranchTrueFalseTotal
unless grep {$_ eq $location;} @{$directive->locations or [];} 2 57 59
Condition50%1/2
$directive->locations || []
l!l
590
MC/DC0%0/1
$directive->locations || []
$directive->locations
Truth table50%1/2
A
A= $directive->locations
Aresult
11
00
268  
269 59 ▶ my $arguments = $application->{arguments} || {};
Condition100%2/2
$application->{'arguments'} || {}
l!l
3920
MC/DC100%1/1
$application->{'arguments'} || {}
$application->{'arguments'}
Truth table100%2/2
A
A= $application->{'arguments'}
Aresult
11
00
270 59 ▶ my $definitions = $directive->args || {};
Condition50%1/2
$directive->args || {}
l!l
590
MC/DC0%0/1
$directive->args || {}
$directive->args
Truth table50%1/2
A
A= $directive->args
Aresult
11
00
271 59 for my $arg_name (sort keys %$arguments) {
272 42 my $definition = $definitions->{$arg_name};
273 42 ▶ if (!$definition) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($definition) 1 41 42
274 1 push @errors, "Unknown argument '$arg_name' on directive '\@$name' at $coordinate.";
275 1 next;
276 }
277 41 ▶ if (my $detail = _missing_required_input_field(
Branch: 1 branch
BranchTrueFalseTotal
if (my $detail = _missing_required_input_field($definition->{"type"}, $arguments->{$arg_name}, "")) 1 40 41
278 $definition->{type}, $arguments->{$arg_name}, q())) {
279 1 push @errors, "Argument '$arg_name' on directive '\@$name' at $coordinate "
280 1 . "is invalid for type @{[$definition->{type}->to_string]}: $detail.";
281 1 next;
282 }
283 40 my $ok = eval { $definition->{type}->graphql_to_perl($arguments->{$arg_name}); 1 };
284 40 ▶ if (!$ok) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($ok) 1 39 40
285 1 ▶ my $detail = $@ || 'invalid value';
Condition50%1/2
$@ || 'invalid value'
l!l
10
MC/DC0%0/1
$@ || 'invalid value'
$@
Truth table50%1/2
A
A= $@
Aresult
11
00
286 1 $detail =~ s/\s+\z//;
287 1 $detail =~ s/ at \S+ line \d+\.?\z//;
288 1 push @errors, "Argument '$arg_name' on directive '\@$name' at $coordinate "
289 1 . "is invalid for type @{[$definition->{type}->to_string]}: $detail.";
290 }
291 }
292 59 for my $arg_name (sort keys %$definitions) {
293 63 my $definition = $definitions->{$arg_name};
294 push @errors, "Required argument '$arg_name' was not provided to directive '\@$name' at $coordinate."
295 if !exists($arguments->{$arg_name})
296 && ref($definition->{type})
297 && $definition->{type}->isa('GraphQL::Houtou::Type::NonNull')
298 63 ▶ && !exists($definition->{default_value});
Branch: 1 branch
BranchTrueFalseTotal
if not exists $arguments->{$arg_name} and ref $definition->{"type"} and $definition->{"type"}->isa("GraphQL::Houtou::Type::NonNull") and not exists $definition->{"default_value"} 1 62 63
Condition77%7/9
not exists $arguments->{$arg_name} and ref $definition->{"type"} and $definition->{"type"}->isa("GraphQL::Houtou::Type::NonNull") and not exists $definition->{"default_value"}
!ll&&!rl&&r
6201
not exists $arguments->{$arg_name} and ref $definition->{"type"} and $definition->{"type"}->isa("GraphQL::Houtou::Type::NonNull")
!ll&&!rl&&r
41211
not exists $arguments->{$arg_name} and ref $definition->{"type"}
!ll&&!rl&&r
41022
MC/DC50%2/4
not exists $arguments->{$arg_name} and ref $definition->{"type"} and $definition->{"type"}->isa("GraphQL::Houtou::Type::NonNull") and not exists $definition->{"default_value"}
not exists $arguments->{$arg_name} ref $definition->{"type"} $definition->{"type"}->isa("GraphQL::Houtou::Type::NonNull") not exists $definition->{"default_value"}
Truth table60%3/5
not(A) and B and C and not(D)
A= not exists $arguments->{$arg_name}B= ref $definition->{"type"}C= $definition->{"type"}->isa("GraphQL::Houtou::Type::NonNull")D= not exists $definition->{"default_value"}
ABCDresult
0XXX0
10XX0
110X0
11100
11111
299 }
300 }
301 806 return @errors;
302 }
303  
304 21 ▶sub _extension_target_copy {
Subroutine _extension_target_copy: called CC=4 SCAR=13.9
305 21 my ($result, $target, $copies) = @_;
306 21 my $key = "$target";
307 21 ▶ return $copies->{$key} if $copies->{$key};
Branch: 1 branch
BranchTrueFalseTotal
if $copies->{$key} 0 21 21
308 21 my $copy = { %$target };
309 21 for my $i (0 .. $#$result) {
310 326 ▶ if ($result->[$i] == $target) {
Branch: 1 branch
BranchTrueFalseTotal
if ($result->[$i] == $target) 21 305 326
311 21 $result->[$i] = $copy;
312 21 last;
313 }
314 }
315 21 return $copies->{$key} = $copy;
316 }
317  
318 13 ▶sub _merge_named_hash {
Subroutine _merge_named_hash: called CC=5 SCAR=16.2
319 13 my ($target, $extension, $key, $type_name) = @_;
320 13 ▶ return if !$extension->{$key};
Branch: 1 branch
BranchTrueFalseTotal
unless $extension->{$key} 0 13 13
321 13 ▶ my %merged = %{ $target->{$key} || {} };
Condition50%1/2
$target->{$key} || {}
l!l
130
MC/DC0%0/1
$target->{$key} || {}
$target->{$key}
Truth table50%1/2
A
A= $target->{$key}
Aresult
11
00
322 13 for my $name (keys %{ $extension->{$key} }) {
323 die "Type extension for '$type_name' redefines $key '$name'.\n"
324 18 ▶ if exists $merged{$name};
Branch: 1 branch
BranchTrueFalseTotal
if exists $merged{$name} 1 17 18
325 17 $merged{$name} = $extension->{$key}{$name};
326 }
327 12 $target->{$key} = \%merged;
328 }
329  
330 11 ▶sub _merge_named_array {
Subroutine _merge_named_array: called CC=5 SCAR=16.1
331 11 my ($target, $extension, $key, $type_name) = @_;
332 11 ▶ return if !$extension->{$key};
Branch: 1 branch
BranchTrueFalseTotal
unless $extension->{$key} 9 2 11
333 2 ▶ my @merged = @{ $target->{$key} || [] };
Condition100%2/2
$target->{$key} || []
l!l
11
MC/DC100%1/1
$target->{$key} || []
$target->{$key}
Truth table100%2/2
A
A= $target->{$key}
Aresult
11
00
334 2 my %seen = map { ($_ => 1) } @merged;
335 2 for my $name (@{ $extension->{$key} }) {
336 die "Type extension for '$type_name' repeats $key member '$name'.\n"
337 2 ▶ if $seen{$name}++;
Branch: 1 branch
BranchTrueFalseTotal
if $seen{$name}++ 0 2 2
338 2 push @merged, $name;
339 }
340 2 $target->{$key} = \@merged;
341 }
342  
343 21 ▶sub _merge_directives {
Subroutine _merge_directives: called CC=7 SCAR=19.5
344 21 my ($target, $extension, $repeatable) = @_;
345 21 ▶ return if !$extension->{directives};
Branch: 1 branch
BranchTrueFalseTotal
unless $extension->{"directives"} 14 7 21
346 7 my %seen;
347 7 ▶ for my $directive (@{ $target->{directives} || [] }, @{ $extension->{directives} }) {
Condition100%2/2
$target->{'directives'} || []
l!l
25
MC/DC100%1/1
$target->{'directives'} || []
$target->{'directives'}
Truth table100%2/2
A
A= $target->{'directives'}
Aresult
11
00
348 9 my $name = $directive->{name};
349 die "Type-system extension repeats non-repeatable directive '\@$name'.\n"
350 9 ▶ if $seen{$name}++ && !$repeatable->{$name};
Branch: 1 branch
BranchTrueFalseTotal
if $seen{$name}++ and not $repeatable->{$name} 1 8 9
Condition100%3/3
$seen{$name}++ and not $repeatable->{$name}
!ll&&!rl&&r
711
MC/DC100%2/2
$seen{$name}++ and not $repeatable->{$name}
$seen{$name}++ not $repeatable->{$name}
Truth table100%3/3
A and not(B)
A= $seen{$name}++B= not $repeatable->{$name}
ABresult
0X0
100
111
351 }
352 $target->{directives} = [
353 6 ▶ @{ $target->{directives} || [] },
Condition100%2/2
$target->{'directives'} || []
l!l
15
MC/DC100%1/1
$target->{'directives'} || []
$target->{'directives'}
Truth table100%2/2
A
A= $target->{'directives'}
Aresult
11
00
354 6 @{ $extension->{directives} },
355 ];
356 }
357  
358 16 ▶sub _merge_type_extension {
Subroutine _merge_type_extension: called CC=8 SCAR=20.8
359 16 my ($target, $extension, $repeatable) = @_;
360 16 my $name = $target->{name};
361 16 _merge_directives($target, $extension, $repeatable);
362 _merge_named_hash($target, $extension, 'fields', $name)
363 if $target->{kind} eq 'type' || $target->{kind} eq 'interface'
364 15 ▶ || $target->{kind} eq 'input';
Branch: 1 branch
BranchTrueFalseTotal
if $target->{"kind"} eq "type" or $target->{"kind"} eq "interface" or $target->{"kind"} eq "input" 12 3 15
Condition100%6/6
$target->{"kind"} eq "type" or $target->{"kind"} eq "interface" or $target->{"kind"} eq "input"
l!l&&r!l&&!r
1113
$target->{"kind"} eq "type" or $target->{"kind"} eq "interface"
l!l&&r!l&&!r
1014
MC/DC100%3/3
$target->{"kind"} eq "type" or $target->{"kind"} eq "interface" or $target->{"kind"} eq "input"
$target->{"kind"} eq "type" $target->{"kind"} eq "interface" $target->{"kind"} eq "input"
Truth table100%4/4
A or B or C
A= $target->{"kind"} eq "type"B= $target->{"kind"} eq "interface"C= $target->{"kind"} eq "input"
ABCresult
1XX1
01X1
0011
0000
365 _merge_named_hash($target, $extension, 'values', $name)
366 14 ▶ if $target->{kind} eq 'enum';
Branch: 1 branch
BranchTrueFalseTotal
if $target->{"kind"} eq "enum" 1 13 14
367 _merge_named_array($target, $extension, 'interfaces', $name)
368 14 ▶ if $target->{kind} eq 'type' || $target->{kind} eq 'interface';
Branch: 1 branch
BranchTrueFalseTotal
if $target->{"kind"} eq "type" or $target->{"kind"} eq "interface" 10 4 14
Condition100%3/3
$target->{"kind"} eq "type" or $target->{"kind"} eq "interface"
l!l&&r!l&&!r
914
MC/DC100%2/2
$target->{"kind"} eq "type" or $target->{"kind"} eq "interface"
$target->{"kind"} eq "type" $target->{"kind"} eq "interface"
Truth table100%3/3
A or B
A= $target->{"kind"} eq "type"B= $target->{"kind"} eq "interface"
ABresult
1X1
011
000
369 _merge_named_array($target, $extension, 'types', $name)
370 14 ▶ if $target->{kind} eq 'union';
Branch: 1 branch
BranchTrueFalseTotal
if $target->{"kind"} eq "union" 1 13 14
371 }
372  
373 5 ▶sub _merge_schema_extension {
Subroutine _merge_schema_extension: called CC=4 SCAR=13.9
374 5 my ($target, $extension, $repeatable) = @_;
375 5 _merge_directives($target, $extension, $repeatable);
376 5 for my $operation (@ROOT_ATTRS) {
377 15 ▶ next if !$extension->{$operation};
Branch: 1 branch
BranchTrueFalseTotal
unless $extension->{$operation} 14 1 15
378 die "Schema extension redefines $operation root type.\n"
379 1 ▶ if $target->{$operation};
Branch: 1 branch
BranchTrueFalseTotal
if $target->{$operation} 0 1 1
380 1 $target->{$operation} = $extension->{$operation};
381 }
382 }
383  
384 20 ▶sub _apply_resolvers {
Subroutine _apply_resolvers: called CC=14 SCAR=26.8
385 20 my ($self, $resolvers) = @_;
386 20 my $name2type = $self->name2type;
387 20 for my $type_name (sort keys %$resolvers) {
388 41 ▶ my $type = $name2type->{$type_name}
Condition100%2/2
$name2type->{$type_name} // die("Cannot attach resolvers to unknown type '${type_name}'.\n")
l!l
401
MC/DC100%1/1
$name2type->{$type_name} // die("Cannot attach resolvers to unknown type '${type_name}'.\n")
$name2type->{$type_name}
Truth table100%2/2
A
A= $name2type->{$type_name}
Aresult
11
00
389 // die "Cannot attach resolvers to unknown type '$type_name'.\n";
390 40 my $spec = $resolvers->{$type_name};
391 40 ▶ die "Resolvers for '$type_name' must be a hash reference.\n"
Branch: 1 branch
BranchTrueFalseTotal
if ref $spec ne "HASH" 0 40 40
392 if ref($spec) ne 'HASH';
393 40 for my $key (sort keys %$spec) {
394 58 ▶ if ($key eq 'resolve_type' || $key eq 'tag_resolver' || $key eq 'is_type_of'
Branch: 1 branch
BranchTrueFalseTotal
if ($key eq "resolve_type" or $key eq "tag_resolver" or $key eq "is_type_of" or $key eq "serialize" or $key eq "parse_value") 21 37 58
Condition83%10/12
$key eq "resolve_type" or $key eq "tag_resolver" or $key eq "is_type_of" or $key eq "serialize" or $key eq "parse_value"
l!l&&r!l&&!r
14737
$key eq "resolve_type" or $key eq "tag_resolver" or $key eq "is_type_of" or $key eq "serialize"
l!l&&r!l&&!r
7744
$key eq "resolve_type" or $key eq "tag_resolver" or $key eq "is_type_of"
l!l&&r!l&&!r
7051
$key eq "resolve_type" or $key eq "tag_resolver"
l!l&&r!l&&!r
7051
MC/DC60%3/5
$key eq "resolve_type" or $key eq "tag_resolver" or $key eq "is_type_of" or $key eq "serialize" or $key eq "parse_value"
$key eq "resolve_type" $key eq "tag_resolver" $key eq "is_type_of" $key eq "serialize" $key eq "parse_value"
Truth table66%4/6
A or B or C or D or E
A= $key eq "resolve_type"B= $key eq "tag_resolver"C= $key eq "is_type_of"D= $key eq "serialize"E= $key eq "parse_value"
ABCDEresult
1XXXX1
01XXX1
001XX1
0001X1
000011
000000
395 || $key eq 'serialize' || $key eq 'parse_value') {
396 21 ▶ die "Type '$type_name' does not support '$key'.\n" if !$type->can($key);
Branch: 1 branch
BranchTrueFalseTotal
unless $type->can($key) 0 21 21
397 21 $type->{$key} = $spec->{$key};
398 21 next;
399 }
400 37 ▶ my $fields = $type->can('fields') ? $type->fields : undef;
Branch: 1 branch
BranchTrueFalseTotal
$type->can('fields') ? : 37 0 37
401 die "Cannot attach a field resolver to '$type_name.$key': no such field.\n"
402 37 ▶ if !$fields || !$fields->{$key};
Branch: 1 branch
BranchTrueFalseTotal
unless $fields and $fields->{$key} 1 36 37
Condition66%2/3
$fields and $fields->{$key}
!ll&&!rl&&r
0136
MC/DC50%1/2
$fields and $fields->{$key}
$fields $fields->{$key}
Truth table66%2/3
A and B
A= $fieldsB= $fields->{$key}
ABresult
0X0
100
111
403 36 $fields->{$key}{resolve} = $spec->{$key};
404 }
405 }
406 18 return $self;
407 }
408  
409 62 my %BUILTIN_SCALARS = map { ($_ => 1) } qw(Int Float String Boolean ID);
410  
411 9 ▶sub to_doc {
Subroutine to_doc: called CC=14 SCAR=26.5
Pod documented
412 9 my ($self) = @_;
413 9 require GraphQL::Houtou::Internal::TypeSupport;
414 9 my @sections;
415  
416 my $default_roots = !grep {
417 9 ▶ $self->$_ && $self->$_->name ne ucfirst $_
Condition100%3/3
$self->$_ && $self->$_->name ne ucfirst $_
!ll&&!rl&&r
1764
MC/DC100%2/2
$self->$_ && $self->$_->name ne ucfirst $_
$self->$_ $self->$_->name ne ucfirst $_
Truth table100%3/3
A && B
A= $self->$_B= $self->$_->name ne ucfirst $_
ABresult
0X0
100
111
418 } @ROOT_ATTRS;
419 9 ▶ if ($self->description || !$default_roots) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->description or not $default_roots) 3 6 9
Condition100%3/3
$self->description or not $default_roots
l!l&&r!l&&!r
126
MC/DC100%2/2
$self->description or not $default_roots
$self->description not $default_roots
Truth table100%3/3
A or not(B)
A= $self->descriptionB= not $default_roots
ABresult
1X1
011
000
420 push @sections, join '', map "$_\n",
421 GraphQL::Houtou::Internal::TypeSupport::description_doc_lines($self->description),
422 'schema {',
423 3 ▶ (map { $self->$_ ? " $_: @{[$self->$_->name]}" : () } @ROOT_ATTRS),
Branch: 1 branch
BranchTrueFalseTotal
$self->$_ ? : 4 5 9
424 '}';
425 }
426  
427 9 my %specified = map { ($_->name => 1) } @GraphQL::Houtou::Directive::SPECIFIED_DIRECTIVES;
428 9 ▶ for my $directive (sort { $a->name cmp $b->name } @{ $self->directives || [] }) {
Condition50%1/2
$self->directives || []
l!l
90
MC/DC0%0/1
$self->directives || []
$self->directives
Truth table50%1/2
A
A= $self->directives
Aresult
11
00
429 51 ▶ next if $specified{ $directive->name };
Branch: 1 branch
BranchTrueFalseTotal
if $specified{$directive->name} 45 6 51
430 6 push @sections, $directive->to_doc;
431 }
432  
433 9 my $name2type = $self->name2type;
434 9 for my $name (sort keys %$name2type) {
435 250 ▶ my $type = $name2type->{$name} or next;
Branch: 1 branch
BranchTrueFalseTotal
my $type = $name2type->{$name} or next 250 0 250
436 250 ▶ next if $BUILTIN_SCALARS{$name};
Branch: 1 branch
BranchTrueFalseTotal
if $BUILTIN_SCALARS{$name} 45 205 250
437 205 ▶ next if $name =~ /\A__/;
Branch: 1 branch
BranchTrueFalseTotal
if $name =~ /\A__/u 72 133 205
438 133 ▶ next if $type->can('is_introspection') && $type->is_introspection;
Branch: 1 branch
BranchTrueFalseTotal
if $type->can("is_introspection") and $type->is_introspection 0 133 133
Condition33%1/3
$type->can("is_introspection") and $type->is_introspection
!ll&&!rl&&r
01330
MC/DC0%0/2
$type->can("is_introspection") and $type->is_introspection
$type->can("is_introspection") $type->is_introspection
Truth table33%1/3
A and B
A= $type->can("is_introspection")B= $type->is_introspection
ABresult
0X0
100
111
439 133 push @sections, $type->to_doc;
440 }
441  
442 9 return join "\n", @sections;
443 }
444  
445 1839 ▶sub name2type {
Subroutine name2type: called CC=2 SCAR=7.1
Pod undocumented
446 1839 my ($self) = @_;
447 1839 ▶ return $self->{name2type} ||= $self->_build_name2type;
Condition66%2/3
$self->{"name2type"} ||= $self->_build_name2type
l!l&&r!l&&!r
15902490
MC/DC0%0/2
$self->{"name2type"} ||= $self->_build_name2type
$self->{"name2type"} $self->_build_name2type
Truth table66%2/3
A ||= B
A= $self->{"name2type"}B= $self->_build_name2type
ABresult
1X1
011
000
448 }
449  
450 493 ▶sub name2directive {
Subroutine name2directive: called CC=2 SCAR=7.1
Pod undocumented
451 493 my ($self) = @_;
452 493 ▶ return $self->{name2directive} ||= $self->_build_name2directive;
Condition66%2/3
$self->{"name2directive"} ||= $self->_build_name2directive
l!l&&r!l&&!r
3181750
MC/DC0%0/2
$self->{"name2directive"} ||= $self->_build_name2directive
$self->{"name2directive"} $self->_build_name2directive
Truth table66%2/3
A ||= B
A= $self->{"name2directive"}B= $self->_build_name2directive
ABresult
1X1
011
000
453 }
454  
455 400 ▶sub _interface2types {
Subroutine _interface2types: called CC=2 SCAR=7.1
456 400 my ($self) = @_;
457 400 ▶ return $self->{_interface2types} ||= $self->_build__interface2types;
Condition66%2/3
$self->{"_interface2types"} ||= $self->_build__interface2types
l!l&&r!l&&!r
2111890
MC/DC0%0/2
$self->{"_interface2types"} ||= $self->_build__interface2types
$self->{"_interface2types"} $self->_build__interface2types
Truth table66%2/3
A ||= B
A= $self->{"_interface2types"}B= $self->_build__interface2types
ABresult
1X1
011
000
458 }
459  
460 194 ▶sub _possible_type_map {
Subroutine _possible_type_map: called CC=2 SCAR=7.1
461 194 my ($self, @set) = @_;
462 194 ▶ $self->{_possible_type_map} = $set[0] if @set;
Branch: 1 branch
BranchTrueFalseTotal
if @set 0 194 194
463 194 return $self->{_possible_type_map};
464 }
465  
466 214 ▶sub prepare_runtime {
Subroutine prepare_runtime: called CC=1 SCAR=0.0
Pod undocumented
467 214 my ($self) = @_;
468 214 return $self->_runtime_cache;
469 }
470  
471 215 ▶sub compile_runtime {
Subroutine compile_runtime: called CC=1 SCAR=0.0
Pod undocumented
472 215 my ($self, %opts) = @_;
473 215 $self->assert_valid;
474 207 return GraphQL::Houtou::Runtime::SchemaGraph->compile_schema($self, %opts);
475 }
476  
477 215 ▶sub assert_valid {
Subroutine assert_valid: called CC=3 SCAR=11.0
Pod documented
478 215 my ($self) = @_;
479 215 ▶ return $self if $self->{_schema_validated};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"_schema_validated"} 18 197 215
480 197 my $errors = $self->validation_errors;
481 197 ▶ die join("\n", 'Schema validation failed:', map { " - $_" } @$errors) . "\n"
Branch: 1 branch
BranchTrueFalseTotal
if @$errors 8 189 197
482 if @$errors;
483 189 $self->{_schema_validated} = 1;
484 189 return $self;
485 }
486  
487 230 ▶sub validation_errors {
Subroutine validation_errors: called CC=74 SCAR=48.2
Pod documented
488 230 my ($self) = @_;
489 230 ▶ my @errors = @{ $self->{_ast_validation_errors} || [] };
Condition100%2/2
$self->{'_ast_validation_errors'} || []
l!l
29201
MC/DC100%1/1
$self->{'_ast_validation_errors'} || []
$self->{'_ast_validation_errors'}
Truth table100%2/2
A
A= $self->{'_ast_validation_errors'}
Aresult
11
00
490 230 my $name2type = eval { $self->name2type };
491 230 ▶ if (!$name2type) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($name2type) 1 229 230
492 1 ▶ my $error = $@ || 'unknown error';
Condition50%1/2
$@ || 'unknown error'
l!l
10
MC/DC0%0/1
$@ || 'unknown error'
$@
Truth table50%1/2
A
A= $@
Aresult
11
00
493 1 $error =~ s/\s+\z//;
494 1 $error =~ s/ at \S+ line \d+\.?\z//;
495 1 return [ $error ];
496 }
497  
498 229 my %root_name;
499 229 for my $operation (@ROOT_ATTRS) {
500 687 ▶ my $root = $self->$operation or next;
Branch: 1 branch
BranchTrueFalseTotal
my $root = $self->$operation or next 247 440 687
501 247 ▶ push @errors, "The $operation root type must be an Object type, found "
Branch: 2 branches
BranchTrueFalseTotal
unless _is_object_type($root) 1 246 247
ref $root && $root->can('to_string') ? : 1 0 1
Condition33%1/3
ref $root and $root->can("to_string")
!ll&&!rl&&r
001
MC/DC0%0/2
ref $root and $root->can("to_string")
ref $root $root->can("to_string")
Truth table33%1/3
A and B
A= ref $rootB= $root->can("to_string")
ABresult
0X0
100
111
502 . (ref($root) && $root->can('to_string') ? $root->to_string : "'$root'") . '.'
503 if !_is_object_type($root);
504 247 ▶ if (ref($root) && $root->can('name') && $root_name{ $root->name }++) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $root and $root->can("name") and $root_name{$root->name}++) 1 246 247
Condition50%3/6
ref $root and $root->can("name") and $root_name{$root->name}++
!ll&&!rl&&r
02461
ref $root and $root->can("name")
!ll&&!rl&&r
00247
MC/DC33%1/3
ref $root and $root->can("name") and $root_name{$root->name}++
ref $root $root->can("name") $root_name{$root->name}++
Truth table50%2/4
A and B and C
A= ref $rootB= $root->can("name")C= $root_name{$root->name}++
ABCresult
0XX0
10X0
1100
1111
505 1 push @errors, "The query, mutation, and subscription root types must be different; "
506 1 . "@{[$root->name]} is used more than once.";
507 }
508 }
509  
510 229 my %directive_name;
511 229 ▶ for my $directive (@{ $self->directives || [] }) {
Condition50%1/2
$self->directives || []
l!l
2290
MC/DC0%0/1
$self->directives || []
$self->directives
Truth table50%1/2
A
A= $self->directives
Aresult
11
00
512 1228 ▶ next if !ref($directive) || !$directive->can('name');
Branch: 1 branch
BranchTrueFalseTotal
unless ref $directive and $directive->can("name") 0 1228 1228
Condition33%1/3
ref $directive and $directive->can("name")
!ll&&!rl&&r
001228
MC/DC0%0/2
ref $directive and $directive->can("name")
ref $directive $directive->can("name")
Truth table33%1/3
A and B
A= ref $directiveB= $directive->can("name")
ABresult
0X0
100
111
513 1228 my $name = $directive->name;
514 push @errors, "Directive '\@$name' is defined more than once."
515 1228 ▶ if $directive_name{$name}++;
Branch: 1 branch
BranchTrueFalseTotal
if $directive_name{$name}++ 1 1227 1228
516 1228 push @errors, _reserved_name_error('Directive', $name);
517 1228 my %location;
518 1228 ▶ my $locations = $directive->locations || [];
Condition50%1/2
$directive->locations || []
l!l
12280
MC/DC0%0/1
$directive->locations || []
$directive->locations
Truth table50%1/2
A
A= $directive->locations
Aresult
11
00
519 1228 ▶ push @errors, "Directive '\@$name' must include one or more locations."
Branch: 1 branch
BranchTrueFalseTotal
unless @$locations 1 1227 1228
520 if !@$locations;
521 1228 for my $location (@$locations) {
522 push @errors, "Directive '\@$name' has unknown location '$location'."
523 2971 ▶ if !$VALID_DIRECTIVE_LOCATION{$location};
Branch: 1 branch
BranchTrueFalseTotal
unless $VALID_DIRECTIVE_LOCATION{$location} 2 2969 2971
524 push @errors, "Directive '\@$name' repeats location '$location'."
525 2971 ▶ if $location{$location}++;
Branch: 1 branch
BranchTrueFalseTotal
if $location{$location}++ 2 2969 2971
526 }
527 1228 ▶ for my $arg_name (sort keys %{ $directive->args || {} }) {
Condition50%1/2
$directive->args || {}
l!l
12280
MC/DC0%0/1
$directive->args || {}
$directive->args
Truth table50%1/2
A
A= $directive->args
Aresult
11
00
528 988 my $arg = $directive->args->{$arg_name};
529 988 push @errors, _reserved_name_error(
530 988 "Argument $arg_name on directive @{[$directive->name]}", $arg_name,
531 );
532 988 push @errors, _default_value_error(
533 988 "directive @{[$directive->name]} argument $arg_name", $arg,
534 );
535 988 push @errors, _required_deprecation_error(
536 'argument @' . $directive->name . "($arg_name:)", $arg,
537 );
538 }
539 }
540  
541 229 for my $type_name (sort keys %$name2type) {
542 3650 ▶ my $type = $name2type->{$type_name} or next;
Branch: 1 branch
BranchTrueFalseTotal
my $type = $name2type->{$type_name} or next 3650 0 3650
543 3650 ▶ next if $type->can('is_introspection') && $type->{is_introspection};
Branch: 1 branch
BranchTrueFalseTotal
if $type->can("is_introspection") and $type->{"is_introspection"} 1832 1818 3650
Condition66%2/3
$type->can("is_introspection") and $type->{"is_introspection"}
!ll&&!rl&&r
018181832
MC/DC50%1/2
$type->can("is_introspection") and $type->{"is_introspection"}
$type->can("is_introspection") $type->{"is_introspection"}
Truth table66%2/3
A and B
A= $type->can("is_introspection")B= $type->{"is_introspection"}
ABresult
0X0
100
111
544  
545 1818 push @errors, _reserved_name_error('Type', $type_name);
546 1818 ▶ if ($type->can('fields')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($type->can("fields")) 608 1210 1818
547 608 ▶ my $fields = $type->fields || {};
Condition50%1/2
$type->fields || {}
l!l
6080
MC/DC0%0/1
$type->fields || {}
$type->fields
Truth table50%1/2
A
A= $type->fields
Aresult
11
00
548 608 for my $field_name (sort keys %$fields) {
549 1309 my $field = $fields->{$field_name};
550 1309 ▶ push @errors, _reserved_name_error(
Branch: 1 branch
BranchTrueFalseTotal
_is_input_type($type) ? : 46 1263 1309
551 (_is_input_type($type) ? 'Input field' : 'Field')
552 . " $type_name.$field_name",
553 $field_name,
554 );
555 1309 ▶ for my $arg_name (sort keys %{ $field->{args} || {} }) {
Condition100%2/2
$field->{'args'} || {}
l!l
2381071
MC/DC100%1/1
$field->{'args'} || {}
$field->{'args'}
Truth table100%2/2
A
A= $field->{'args'}
Aresult
11
00
556 399 my $arg = $field->{args}{$arg_name};
557 399 push @errors, _reserved_name_error(
558 "Argument $type_name.$field_name($arg_name:)", $arg_name,
559 );
560 399 push @errors, _default_value_error(
561 "argument $type_name.$field_name($arg_name:)", $arg,
562 );
563 399 push @errors, _required_deprecation_error(
564 "argument $type_name.$field_name($arg_name:)", $arg,
565 );
566 }
567 }
568 }
569 1818 ▶ if ($type->isa('GraphQL::Houtou::Type::Enum')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($type->isa("GraphQL::Houtou::Type::Enum")) 13 1805 1818
570 13 ▶ for my $value_name (sort keys %{ $type->values || {} }) {
Condition50%1/2
$type->values || {}
l!l
130
MC/DC0%0/1
$type->values || {}
$type->values
Truth table50%1/2
A
A= $type->values
Aresult
11
00
571 25 push @errors, _reserved_name_error(
572 "Enum value $type_name.$value_name", $value_name,
573 );
574 }
575 }
576  
577 1818 ▶ if (_is_object_type($type)) {
Branch: 5 branches
BranchTrueFalseTotal
if (_is_object_type($type)) { } 533 1285 1818
elsif (_is_interface_type($type)) { } 44 1241 1285
elsif ($type->isa('GraphQL::Houtou::Type::Union')) { } 16 1225 1241
elsif ($type->isa('GraphQL::Houtou::Type::Enum')) { } 13 1212 1225
elsif ($type->isa('GraphQL::Houtou::Type::InputObject')) { } 31 1181 1212
578 1 push @errors, "Object type @{[$type->name]} must define one or more fields."
579 533 ▶ if !keys %{ $type->fields || {} };
Branch: 1 branch
BranchTrueFalseTotal
unless keys %{$type->fields or {};} 1 532 533
Condition50%1/2
$type->fields || {}
l!l
5330
MC/DC0%0/1
$type->fields || {}
$type->fields
Truth table50%1/2
A
A= $type->fields
Aresult
11
00
580 533 push @errors, _implemented_interface_errors($type);
581 533 push @errors, $self->_object_field_errors($type);
582 533 ▶ for my $interface (@{ $type->interfaces || [] }) {
Condition50%1/2
$type->interfaces || []
l!l
5330
MC/DC0%0/1
$type->interfaces || []
$type->interfaces
Truth table50%1/2
A
A= $type->interfaces
Aresult
11
00
583 47 ▶ if (!ref($interface) || !_is_interface_type($interface)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $interface and _is_interface_type($interface)) 0 47 47
Condition33%1/3
ref $interface and _is_interface_type($interface)
!ll&&!rl&&r
0047
MC/DC0%0/2
ref $interface and _is_interface_type($interface)
ref $interface _is_interface_type($interface)
Truth table33%1/3
A and B
A= ref $interfaceB= _is_interface_type($interface)
ABresult
0X0
100
111
584 0 ▶ push @errors, "Type @{[$type->name]} must only implement Interface types, "
Branch: 1 branch
BranchTrueFalseTotal
ref $interface ? : 0 0 0
585 . 'found ' . (ref($interface) ? $interface->to_string : "'$interface'") . '.';
586 0 next;
587 }
588 47 push @errors, $self->_interface_conformance_errors($type, $interface);
589 }
590 }
591 elsif (_is_interface_type($type)) {
592 1 push @errors, "Interface type @{[$type->name]} must define one or more fields."
593 44 ▶ if !keys %{ $type->fields || {} };
Branch: 1 branch
BranchTrueFalseTotal
unless keys %{$type->fields or {};} 1 43 44
Condition50%1/2
$type->fields || {}
l!l
440
MC/DC0%0/1
$type->fields || {}
$type->fields
Truth table50%1/2
A
A= $type->fields
Aresult
11
00
594 44 push @errors, _implemented_interface_errors($type);
595 44 push @errors, $self->_object_field_errors($type);
596 44 ▶ for my $interface (@{ $type->interfaces || [] }) {
Condition50%1/2
$type->interfaces || []
l!l
440
MC/DC0%0/1
$type->interfaces || []
$type->interfaces
Truth table50%1/2
A
A= $type->interfaces
Aresult
11
00
597 11 ▶ if (!ref($interface) || !_is_interface_type($interface)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $interface and _is_interface_type($interface)) 0 11 11
Condition33%1/3
ref $interface and _is_interface_type($interface)
!ll&&!rl&&r
0011
MC/DC0%0/2
ref $interface and _is_interface_type($interface)
ref $interface _is_interface_type($interface)
Truth table33%1/3
A and B
A= ref $interfaceB= _is_interface_type($interface)
ABresult
0X0
100
111
598 0 ▶ push @errors, "Type @{[$type->name]} must only implement Interface types, "
Branch: 1 branch
BranchTrueFalseTotal
ref $interface ? : 0 0 0
599 . 'found ' . (ref($interface) ? $interface->to_string : "'$interface'") . '.';
600 0 next;
601 }
602 11 push @errors, $self->_interface_conformance_errors($type, $interface);
603 }
604 }
605 elsif ($type->isa('GraphQL::Houtou::Type::Union')) {
606 16 ▶ my $members = $type->types || [];
Condition50%1/2
$type->types || []
l!l
160
MC/DC0%0/1
$type->types || []
$type->types
Truth table50%1/2
A
A= $type->types
Aresult
11
00
607 0 ▶ push @errors, "Union type @{[$type->name]} must define one or more member types."
Branch: 1 branch
BranchTrueFalseTotal
unless @$members 0 16 16
608 if !@$members;
609 16 for my $member (@$members) {
610 0 ▶ push @errors, "Union type @{[$type->name]} can only include Object types, "
Branch: 2 branches
BranchTrueFalseTotal
unless ref $member and _is_object_type($member) 0 22 22
ref $member ? : 0 0 0
Condition33%1/3
ref $member and _is_object_type($member)
!ll&&!rl&&r
0022
MC/DC0%0/2
ref $member and _is_object_type($member)
ref $member _is_object_type($member)
Truth table33%1/3
A and B
A= ref $memberB= _is_object_type($member)
ABresult
0X0
100
111
611 . 'found ' . (ref($member) ? $member->to_string : "'$member'") . '.'
612 if !ref($member) || !_is_object_type($member);
613 }
614 }
615 elsif ($type->isa('GraphQL::Houtou::Type::Enum')) {
616 1 push @errors, "Enum type @{[$type->name]} must define one or more values."
617 13 ▶ if !keys %{ $type->values || {} };
Branch: 1 branch
BranchTrueFalseTotal
unless keys %{$type->values or {};} 1 12 13
Condition50%1/2
$type->values || {}
l!l
130
MC/DC0%0/1
$type->values || {}
$type->values
Truth table50%1/2
A
A= $type->values
Aresult
11
00
618 }
619 elsif ($type->isa('GraphQL::Houtou::Type::InputObject')) {
620 31 ▶ my $fields = $type->fields || {};
Condition50%1/2
$type->fields || {}
l!l
310
MC/DC0%0/1
$type->fields || {}
$type->fields
Truth table50%1/2
A
A= $type->fields
Aresult
11
00
621 31 ▶ push @errors, "Input Object type @{[$type->name]} must define one or more fields."
Branch: 1 branch
BranchTrueFalseTotal
unless keys %$fields 1 30 31
622 if !keys %$fields;
623 31 ▶ my $is_one_of = $type->can('is_one_of') && $type->is_one_of;
Condition66%2/3
$type->can('is_one_of') && $type->is_one_of
!ll&&!rl&&r
0238
MC/DC50%1/2
$type->can('is_one_of') && $type->is_one_of
$type->can('is_one_of') $type->is_one_of
Truth table66%2/3
A && B
A= $type->can('is_one_of')B= $type->is_one_of
ABresult
0X0
100
111
624 31 for my $field_name (sort keys %$fields) {
625 46 my $field = $fields->{$field_name};
626 46 my $field_type = $field->{type};
627 46 ▶ push @errors, "The type of @{[$type->name]}.$field_name must be Input Type"
Branch: 2 branches
BranchTrueFalseTotal
unless _is_input_type($field_type) 1 45 46
ref $field_type ? : 1 0 1
628 . (ref($field_type) ? ' but got: ' . $field_type->to_string . '.' : '.')
629 if !_is_input_type($field_type);
630 46 push @errors, _default_value_error(
631 46 "input field @{[$type->name]}.$field_name", $field,
632 );
633 46 push @errors, _required_deprecation_error(
634 46 "input field @{[$type->name]}.$field_name", $field,
635 );
636 46 ▶ if ($is_one_of) {
Branch: 1 branch
BranchTrueFalseTotal
if ($is_one_of) 16 30 46
637 16 ▶ push @errors, "OneOf input field @{[$type->name]}.$field_name must be nullable."
Branch: 1 branch
BranchTrueFalseTotal
if ref $field_type and $field_type->isa("GraphQL::Houtou::Type::NonNull") 1 15 16
Condition66%2/3
ref $field_type and $field_type->isa("GraphQL::Houtou::Type::NonNull")
!ll&&!rl&&r
0151
MC/DC50%1/2
ref $field_type and $field_type->isa("GraphQL::Houtou::Type::NonNull")
ref $field_type $field_type->isa("GraphQL::Houtou::Type::NonNull")
Truth table66%2/3
A and B
A= ref $field_typeB= $field_type->isa("GraphQL::Houtou::Type::NonNull")
ABresult
0X0
100
111
638 if ref($field_type) && $field_type->isa('GraphQL::Houtou::Type::NonNull');
639 1 push @errors, "OneOf input field @{[$type->name]}.$field_name cannot have a default value."
640 16 ▶ if exists $field->{default_value};
Branch: 1 branch
BranchTrueFalseTotal
if exists $field->{"default_value"} 1 15 16
641 }
642 }
643 }
644 }
645  
646 229 push @errors, $self->_input_object_cycle_errors($name2type);
647 229 push @errors, $self->_interface_cycle_errors($name2type);
648  
649 229 return \@errors;
650 }
651  
652 229 ▶sub _interface_cycle_errors {
Subroutine _interface_cycle_errors: called CC=5 SCAR=16.2
653 229 my ($self, $name2type) = @_;
654 229 my (@errors, %state, @path, %path_index);
655  
656 229 my $visit;
657 44 ▶ $visit = sub {
Subroutine __ANON__: called CC=8 SCAR=21.0
658 44 my ($type) = @_;
659 44 my $name = $type->name;
660 44 $state{$name} = 1;
661 44 $path_index{$name} = scalar @path;
662 44 push @path, $name;
663  
664 44 ▶ for my $next (@{ $type->interfaces || [] }) {
Condition50%1/2
$type->interfaces || []
l!l
440
MC/DC0%0/1
$type->interfaces || []
$type->interfaces
Truth table50%1/2
A
A= $type->interfaces
Aresult
11
00
665 11 ▶ next if !ref($next) || !_is_interface_type($next);
Branch: 1 branch
BranchTrueFalseTotal
unless ref $next and _is_interface_type($next) 0 11 11
Condition33%1/3
ref $next and _is_interface_type($next)
!ll&&!rl&&r
0011
MC/DC0%0/2
ref $next and _is_interface_type($next)
ref $next _is_interface_type($next)
Truth table33%1/3
A and B
A= ref $nextB= _is_interface_type($next)
ABresult
0X0
100
111
666 11 my $next_name = $next->name;
667 11 ▶ if (($state{$next_name} || 0) == 1) {
Branch: 2 branches
BranchTrueFalseTotal
if (($state{$next_name} || 0) == 1) { } 2 9 11
elsif (not $state{$next_name}) { } 4 5 9
Condition100%2/2
$state{$next_name} || 0
l!l
74
MC/DC100%1/1
$state{$next_name} || 0
$state{$next_name}
Truth table100%2/2
A
A= $state{$next_name}
Aresult
11
00
668 2 my @cycle = (@path[$path_index{$next_name} .. $#path], $next_name);
669 2 push @errors, 'Interface implementation cannot contain a circular reference: '
670 . join(' -> ', @cycle) . '.';
671 }
672 elsif (!$state{$next_name}) {
673 4 $visit->($next);
674 }
675 }
676  
677 44 pop @path;
678 44 delete $path_index{$name};
679 44 $state{$name} = 2;
680 44 return;
681 229 };
682  
683 229 for my $name (sort keys %$name2type) {
684 3650 my $type = $name2type->{$name};
685 3650 ▶ next if !$type || !_is_interface_type($type) || $state{$name};
Branch: 1 branch
BranchTrueFalseTotal
if not $type && _is_interface_type($type) or $state{$name} 3610 40 3650
Condition83%5/6
not $type && _is_interface_type($type) or $state{$name}
l!l&&r!l&&!r
3606440
$type && _is_interface_type($type)
!ll&&!rl&&r
0360644
MC/DC66%2/3
not $type && _is_interface_type($type) or $state{$name}
$type _is_interface_type($type) $state{$name}
Truth table75%3/4
not(A && B) or C
A= $typeB= _is_interface_type($type)C= $state{$name}
ABCresult
0XX1
10X1
1111
1100
686 40 $visit->($type);
687 }
688 229 return @errors;
689 }
690  
691 229 ▶sub _input_object_cycle_errors {
Subroutine _input_object_cycle_errors: called CC=5 SCAR=16.1
692 229 my ($self, $name2type) = @_;
693 229 my (@errors, %state, @path, %path_index);
694  
695 229 my $visit;
696 31 ▶ $visit = sub {
Subroutine __ANON__: called CC=7 SCAR=19.5
697 31 my ($type) = @_;
698 31 my $name = $type->name;
699 31 $state{$name} = 1;
700 31 $path_index{$name} = scalar @path;
701 31 push @path, $name;
702  
703 31 ▶ for my $field_name (sort keys %{ $type->fields || {} }) {
Condition50%1/2
$type->fields || {}
l!l
310
MC/DC0%0/1
$type->fields || {}
$type->fields
Truth table50%1/2
A
A= $type->fields
Aresult
11
00
704 46 my $next = _required_singular_input_object($type->fields->{$field_name}{type});
705 46 ▶ next if !$next;
Branch: 1 branch
BranchTrueFalseTotal
unless $next 44 2 46
706 2 my $next_name = $next->name;
707 2 ▶ if (($state{$next_name} || 0) == 1) {
Branch: 2 branches
BranchTrueFalseTotal
if (($state{$next_name} || 0) == 1) { } 1 1 2
elsif (not $state{$next_name}) { } 1 0 1
Condition100%2/2
$state{$next_name} || 0
l!l
11
MC/DC100%1/1
$state{$next_name} || 0
$state{$next_name}
Truth table100%2/2
A
A= $state{$next_name}
Aresult
11
00
708 1 my @cycle = (@path[$path_index{$next_name} .. $#path], $next_name);
709 1 push @errors, 'Input Object circular reference cannot form an unbroken chain '
710 . 'of singular Non-Null fields: ' . join(' -> ', @cycle) . '.';
711 }
712 elsif (!$state{$next_name}) {
713 1 $visit->($next);
714 }
715 }
716  
717 31 pop @path;
718 31 delete $path_index{$name};
719 31 $state{$name} = 2;
720 31 return;
721 229 };
722  
723 229 for my $name (sort keys %$name2type) {
724 3650 my $type = $name2type->{$name};
725 3650 ▶ next if !$type || !$type->isa('GraphQL::Houtou::Type::InputObject') || $state{$name};
Branch: 1 branch
BranchTrueFalseTotal
if not $type && $type->isa("GraphQL::Houtou::Type::InputObject") or $state{$name} 3620 30 3650
Condition83%5/6
not $type && $type->isa("GraphQL::Houtou::Type::InputObject") or $state{$name}
l!l&&r!l&&!r
3619130
$type && $type->isa('GraphQL::Houtou::Type::InputObject')
!ll&&!rl&&r
0361931
MC/DC66%2/3
not $type && $type->isa("GraphQL::Houtou::Type::InputObject") or $state{$name}
$type $type->isa('GraphQL::Houtou::Type::InputObject') $state{$name}
Truth table75%3/4
not(A && B) or C
A= $typeB= $type->isa('GraphQL::Houtou::Type::InputObject')C= $state{$name}
ABCresult
0XX1
10X1
1111
1100
726 30 $visit->($type);
727 }
728 229 return @errors;
729 }
730  
731 46 ▶sub _required_singular_input_object {
Subroutine _required_singular_input_object: called CC=6 SCAR=18.0
732 46 my ($type) = @_;
733 46 ▶ return if !ref($type) || !$type->isa('GraphQL::Houtou::Type::NonNull');
Branch: 1 branch
BranchTrueFalseTotal
unless ref $type and $type->isa("GraphQL::Houtou::Type::NonNull") 32 14 46
Condition66%2/3
ref $type and $type->isa("GraphQL::Houtou::Type::NonNull")
!ll&&!rl&&r
03214
MC/DC50%1/2
ref $type and $type->isa("GraphQL::Houtou::Type::NonNull")
ref $type $type->isa("GraphQL::Houtou::Type::NonNull")
Truth table66%2/3
A and B
A= ref $typeB= $type->isa("GraphQL::Houtou::Type::NonNull")
ABresult
0X0
100
111
734 14 my $of = $type->of;
735 14 ▶ return if !ref($of) || $of->isa('GraphQL::Houtou::Type::List');
Branch: 1 branch
BranchTrueFalseTotal
if not ref $of or $of->isa("GraphQL::Houtou::Type::List") 1 13 14
Condition66%2/3
not ref $of or $of->isa("GraphQL::Houtou::Type::List")
l!l&&r!l&&!r
0113
MC/DC50%1/2
not ref $of or $of->isa("GraphQL::Houtou::Type::List")
not ref $of $of->isa("GraphQL::Houtou::Type::List")
Truth table66%2/3
not(A) or B
A= not ref $ofB= $of->isa("GraphQL::Houtou::Type::List")
ABresult
1X1
011
000
736 13 ▶ return $of if $of->isa('GraphQL::Houtou::Type::InputObject');
Branch: 1 branch
BranchTrueFalseTotal
if $of->isa("GraphQL::Houtou::Type::InputObject") 2 11 13
737 11 return;
738 }
739  
740 5767 ▶sub _reserved_name_error {
Subroutine _reserved_name_error: called CC=3 SCAR=11.0
741 5767 my ($coordinate, $name) = @_;
742 5767 ▶ return () if !defined($name) || $name !~ /\A__/;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $name and $name =~ /\A__/u 5764 3 5767
Condition66%2/3
defined $name and $name =~ /\A__/u
!ll&&!rl&&r
057643
MC/DC50%1/2
defined $name and $name =~ /\A__/u
defined $name $name =~ /\A__/u
Truth table66%2/3
A and B
A= defined $nameB= $name =~ /\A__/u
ABresult
0X0
100
111
743 3 return "$coordinate must not begin with '__', which is reserved for introspection.";
744 }
745  
746 1433 ▶sub _default_value_error {
Subroutine _default_value_error: called CC=6 SCAR=18.0
747 1433 my ($coordinate, $definition) = @_;
748 1433 ▶ return () if !exists $definition->{default_value};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $definition->{"default_value"} 1180 253 1433
749 253 my $type = $definition->{type};
750 253 ▶ return () if !_is_input_type($type);
Branch: 1 branch
BranchTrueFalseTotal
unless _is_input_type($type) 0 253 253
751 253 ▶ if (my $detail = _missing_required_input_field(
Branch: 1 branch
BranchTrueFalseTotal
if (my $detail = _missing_required_input_field($type, $definition->{"default_value"}, "")) 2 251 253
752 $type, $definition->{default_value}, q())) {
753 2 return "The default value for $coordinate is invalid for type "
754 . $type->to_string . ": $detail.";
755 }
756 251 my $ok = eval { $type->graphql_to_perl($definition->{default_value}); 1 };
757 251 ▶ return () if $ok;
Branch: 1 branch
BranchTrueFalseTotal
if $ok 248 3 251
758 3 ▶ my $detail = $@ || 'invalid value';
Condition50%1/2
$@ || 'invalid value'
l!l
30
MC/DC0%0/1
$@ || 'invalid value'
$@
Truth table50%1/2
A
A= $@
Aresult
11
00
759 3 $detail =~ s/\s+\z//;
760 3 $detail =~ s/ at \S+ line \d+\.?\z//;
761 3 return "The default value for $coordinate is invalid for type "
762 . $type->to_string . ": $detail.";
763 }
764  
765 304 ▶sub _missing_required_input_field {
Subroutine _missing_required_input_field: called CC=19 SCAR=29.7
766 304 my ($type, $value, $path) = @_;
767 304 ▶ return if !ref($type) || !defined($value);
Branch: 1 branch
BranchTrueFalseTotal
unless ref $type and defined $value 1 303 304
Condition66%2/3
ref $type and defined $value
!ll&&!rl&&r
01303
MC/DC50%1/2
ref $type and defined $value
ref $type defined $value
Truth table66%2/3
A and B
A= ref $typeB= defined $value
ABresult
0X0
100
111
768 303 ▶ $type = $type->of if $type->isa('GraphQL::Houtou::Type::NonNull');
Branch: 1 branch
BranchTrueFalseTotal
if $type->isa("GraphQL::Houtou::Type::NonNull") 26 277 303
769 303 ▶ if ($type->isa('GraphQL::Houtou::Type::List')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($type->isa("GraphQL::Houtou::Type::List")) 6 297 303
770 6 ▶ my $values = ref($value) eq 'ARRAY' ? $value : [ $value ];
Branch: 1 branch
BranchTrueFalseTotal
ref $value eq 'ARRAY' ? : 5 1 6
771 6 for my $index (0 .. $#$values) {
772 7 my $error = _missing_required_input_field(
773 $type->of, $values->[$index], "$path\[$index\]",
774 );
775 7 ▶ return $error if $error;
Branch: 1 branch
BranchTrueFalseTotal
if $error 1 6 7
776 }
777 5 return;
778 }
779 297 ▶ return if !$type->isa('GraphQL::Houtou::Type::InputObject')
Branch: 1 branch
BranchTrueFalseTotal
if not $type->isa("GraphQL::Houtou::Type::InputObject") or ref $value ne "HASH" 291 6 297
Condition66%2/3
not $type->isa("GraphQL::Houtou::Type::InputObject") or ref $value ne "HASH"
l!l&&r!l&&!r
29106
MC/DC50%1/2
not $type->isa("GraphQL::Houtou::Type::InputObject") or ref $value ne "HASH"
not $type->isa("GraphQL::Houtou::Type::InputObject") ref $value ne "HASH"
Truth table66%2/3
not(A) or B
A= not $type->isa("GraphQL::Houtou::Type::InputObject")B= ref $value ne "HASH"
ABresult
1X1
011
000
780 || ref($value) ne 'HASH';
781  
782 6 ▶ for my $field_name (sort keys %{ $type->fields || {} }) {
Condition50%1/2
$type->fields || {}
l!l
60
MC/DC0%0/1
$type->fields || {}
$type->fields
Truth table50%1/2
A
A= $type->fields
Aresult
11
00
783 9 my $field = $type->fields->{$field_name};
784 9 ▶ my $field_path = length($path) ? "$path.$field_name" : $field_name;
Branch: 1 branch
BranchTrueFalseTotal
length $path ? : 3 6 9
785 9 ▶ if (!exists($value->{$field_name}) && !exists($field->{default_value})
Branch: 1 branch
BranchTrueFalseTotal
if (not exists $value->{$field_name} || exists $field->{"default_value"} and ref $field->{"type"} and $field->{"type"}->isa("GraphQL::Houtou::Type::NonNull")) 3 6 9
Condition77%7/9
not exists $value->{$field_name} || exists $field->{"default_value"} and ref $field->{"type"} and $field->{"type"}->isa("GraphQL::Houtou::Type::NonNull")
!ll&&!rl&&r
333
not exists $value->{$field_name} || exists $field->{"default_value"} and ref $field->{"type"}
!ll&&!rl&&r
306
exists $value->{$field_name} || exists $field->{'default_value'}
l!l&&r!l&&!r
306
MC/DC50%2/4
not exists $value->{$field_name} || exists $field->{"default_value"} and ref $field->{"type"} and $field->{"type"}->isa("GraphQL::Houtou::Type::NonNull")
exists $value->{$field_name} exists $field->{'default_value'} ref $field->{"type"} $field->{"type"}->isa("GraphQL::Houtou::Type::NonNull")
Truth table60%3/5
not(A || B) and C and D
A= exists $value->{$field_name}B= exists $field->{'default_value'}C= ref $field->{"type"}D= $field->{"type"}->isa("GraphQL::Houtou::Type::NonNull")
ABCDresult
1XXX0
01XX0
000X0
00100
00111
786 && ref($field->{type})
787 && $field->{type}->isa('GraphQL::Houtou::Type::NonNull')) {
788 3 return "required input field $field_path is missing";
789 }
790 6 ▶ next if !exists $value->{$field_name};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $value->{$field_name} 3 3 6
791 my $error = _missing_required_input_field(
792 3 $field->{type}, $value->{$field_name}, $field_path,
793 );
794 3 ▶ return $error if $error;
Branch: 1 branch
BranchTrueFalseTotal
if $error 0 3 3
795 }
796 3 return;
797 }
798  
799 1433 ▶sub _required_deprecation_error {
Subroutine _required_deprecation_error: called CC=6 SCAR=18.0
800 1433 my ($coordinate, $definition) = @_;
801 return () if !ref($definition->{type})
802 || !$definition->{type}->isa('GraphQL::Houtou::Type::NonNull')
803 || exists($definition->{default_value})
804 || (!$definition->{is_deprecated}
805 1433 ▶ && !defined($definition->{deprecation_reason}));
Branch: 1 branch
BranchTrueFalseTotal
if not ref $definition->{"type"} && $definition->{"type"}->isa("GraphQL::Houtou::Type::NonNull") or exists $definition->{"default_value"} or not $definition->{"is_deprecated"} || defined $definition->{"deprecation_reason"} 1427 6 1433
Condition83%10/12
not ref $definition->{"type"} && $definition->{"type"}->isa("GraphQL::Houtou::Type::NonNull") or exists $definition->{"default_value"} or not $definition->{"is_deprecated"} || defined $definition->{"deprecation_reason"}
l!l&&r!l&&!r
6547736
not ref $definition->{"type"} && $definition->{"type"}->isa("GraphQL::Houtou::Type::NonNull") or exists $definition->{"default_value"}
l!l&&r!l&&!r
6495779
ref $definition->{'type'} && $definition->{'type'}->isa('GraphQL::Houtou::Type::NonNull')
!ll&&!rl&&r
0649784
$definition->{'is_deprecated'} || defined $definition->{'deprecation_reason'}
l!l&&r!l&&!r
60773
MC/DC60%3/5
not ref $definition->{"type"} && $definition->{"type"}->isa("GraphQL::Houtou::Type::NonNull") or exists $definition->{"default_value"} or not $definition->{"is_deprecated"} || defined $definition->{"deprecation_reason"}
ref $definition->{'type'} $definition->{'type'}->isa('GraphQL::Houtou::Type::NonNull') exists $definition->{"default_value"} $definition->{'is_deprecated'} defined $definition->{'deprecation_reason'}
Truth table66%4/6
not(A && B) or C or not(D || E)
A= ref $definition->{'type'}B= $definition->{'type'}->isa('GraphQL::Houtou::Type::NonNull')C= exists $definition->{"default_value"}D= $definition->{'is_deprecated'}E= defined $definition->{'deprecation_reason'}
ABCDEresult
0XXXX1
10XXX1
111XX1
110001
1101X0
110010
806 6 return "Required $coordinate cannot be deprecated.";
807 }
808  
809 577 ▶sub _implemented_interface_errors {
Subroutine _implemented_interface_errors: called CC=7 SCAR=19.9
810 577 my ($type) = @_;
811 577 my (@errors, %seen);
812 577 ▶ for my $interface (@{ $type->interfaces || [] }) {
Condition50%1/2
$type->interfaces || []
l!l
5770
MC/DC0%0/1
$type->interfaces || []
$type->interfaces
Truth table50%1/2
A
A= $type->interfaces
Aresult
11
00
813 58 ▶ next if !ref($interface) || !$interface->can('name');
Branch: 1 branch
BranchTrueFalseTotal
unless ref $interface and $interface->can("name") 0 58 58
Condition33%1/3
ref $interface and $interface->can("name")
!ll&&!rl&&r
0058
MC/DC0%0/2
ref $interface and $interface->can("name")
ref $interface $interface->can("name")
Truth table33%1/3
A and B
A= ref $interfaceB= $interface->can("name")
ABresult
0X0
100
111
814 58 my $name = $interface->name;
815 1 push @errors, "Type @{[$type->name]} can only implement $name once."
816 58 ▶ if $seen{$name}++;
Branch: 1 branch
BranchTrueFalseTotal
if $seen{$name}++ 1 57 58
817 58 ▶ push @errors, "Type @{[$type->name]} cannot implement itself."
Branch: 1 branch
BranchTrueFalseTotal
if $type == $interface 1 57 58
818 if $type == $interface;
819 }
820 577 return @errors;
821 }
822  
823 577 ▶sub _object_field_errors {
Subroutine _object_field_errors: called CC=9 SCAR=23.0
824 577 my ($self, $type) = @_;
825 577 my @errors;
826 577 ▶ my $fields = $type->fields || {};
Condition50%1/2
$type->fields || {}
l!l
5770
MC/DC0%0/1
$type->fields || {}
$type->fields
Truth table50%1/2
A
A= $type->fields
Aresult
11
00
827 577 for my $field_name (sort keys %$fields) {
828 1263 my $field = $fields->{$field_name};
829 1263 my $field_type = $field->{type};
830 0 ▶ push @errors, "The type of @{[$type->name]}.$field_name must be Output Type"
Branch: 2 branches
BranchTrueFalseTotal
unless _is_output_type($field_type) 0 1263 1263
ref $field_type ? : 0 0 0
831 . (ref($field_type) ? ' but got: ' . $field_type->to_string . '.' : '.')
832 if !_is_output_type($field_type);
833 1263 ▶ for my $arg_name (sort keys %{ $field->{args} || {} }) {
Condition100%2/2
$field->{'args'} || {}
l!l
2381025
MC/DC100%1/1
$field->{'args'} || {}
$field->{'args'}
Truth table100%2/2
A
A= $field->{'args'}
Aresult
11
00
834 399 my $arg_type = $field->{args}{$arg_name}{type};
835 399 ▶ push @errors, "The type of @{[$type->name]}.$field_name($arg_name:) must be Input Type"
Branch: 2 branches
BranchTrueFalseTotal
unless _is_input_type($arg_type) 1 398 399
ref $arg_type ? : 1 0 1
836 . (ref($arg_type) ? ' but got: ' . $arg_type->to_string . '.' : '.')
837 if !_is_input_type($arg_type);
838 }
839 }
840 577 return @errors;
841 }
842  
843 58 ▶sub _interface_conformance_errors {
Subroutine _interface_conformance_errors: called CC=24 SCAR=32.6
844 58 my ($self, $object, $interface) = @_;
845 58 my @errors;
846 58 ▶ my $interface_fields = $interface->fields || {};
Condition50%1/2
$interface->fields || {}
l!l
580
MC/DC0%0/1
$interface->fields || {}
$interface->fields
Truth table50%1/2
A
A= $interface->fields
Aresult
11
00
847 58 ▶ my $object_fields = $object->fields || {};
Condition50%1/2
$object->fields || {}
l!l
580
MC/DC0%0/1
$object->fields || {}
$object->fields
Truth table50%1/2
A
A= $object->fields
Aresult
11
00
848  
849 70 my %implemented = map { ($_->name => 1) }
850 58 ▶ grep { ref($_) } @{ $object->interfaces || [] };
Condition50%1/2
$object->interfaces || []
l!l
580
MC/DC0%0/1
$object->interfaces || []
$object->interfaces
Truth table50%1/2
A
A= $object->interfaces
Aresult
11
00
851 58 ▶ for my $inherited (@{ $interface->interfaces || [] }) {
Condition50%1/2
$interface->interfaces || []
l!l
580
MC/DC0%0/1
$interface->interfaces || []
$interface->interfaces
Truth table50%1/2
A
A= $interface->interfaces
Aresult
11
00
852 4 push @errors, "Type @{[$object->name]} must implement @{[$inherited->name]} "
853 4 . "because it is implemented by @{[$interface->name]}."
854 8 ▶ if !$implemented{ $inherited->name };
Branch: 1 branch
BranchTrueFalseTotal
unless $implemented{$inherited->name} 4 4 8
855 }
856  
857 58 for my $field_name (sort keys %$interface_fields) {
858 81 my $interface_field = $interface_fields->{$field_name};
859 81 my $object_field = $object_fields->{$field_name};
860  
861 81 ▶ if (!$object_field) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($object_field) 4 77 81
862 4 push @errors, "Interface field @{[$interface->name]}.$field_name expected "
863 4 . "but @{[$object->name]} does not provide it.";
864 4 next;
865 }
866  
867 77 ▶ if (ref($interface_field->{type}) && ref($object_field->{type})
Branch: 1 branch
BranchTrueFalseTotal
if (ref $interface_field->{"type"} and ref $object_field->{"type"} and not $self->_is_sub_type($object_field->{"type"}, $interface_field->{"type"})) 1 76 77
Condition50%3/6
ref $interface_field->{"type"} and ref $object_field->{"type"} and not $self->_is_sub_type($object_field->{"type"}, $interface_field->{"type"})
!ll&&!rl&&r
0761
ref $interface_field->{"type"} and ref $object_field->{"type"}
!ll&&!rl&&r
0077
MC/DC33%1/3
ref $interface_field->{"type"} and ref $object_field->{"type"} and not $self->_is_sub_type($object_field->{"type"}, $interface_field->{"type"})
ref $interface_field->{"type"} ref $object_field->{"type"} not $self->_is_sub_type($object_field->{"type"}, $interface_field->{"type"})
Truth table50%2/4
A and B and not(C)
A= ref $interface_field->{"type"}B= ref $object_field->{"type"}C= not $self->_is_sub_type($object_field->{"type"}, $interface_field->{"type"})
ABCresult
0XX0
10X0
1100
1111
868 && !$self->_is_sub_type($object_field->{type}, $interface_field->{type})) {
869 1 push @errors, "Interface field @{[$interface->name]}.$field_name expects type "
870 1 . "@{[$interface_field->{type}->to_string]} but @{[$object->name]}.$field_name "
871 1 . "is type @{[$object_field->{type}->to_string]}.";
872 }
873  
874 77 ▶ my $interface_args = $interface_field->{args} || {};
Condition100%2/2
$interface_field->{'args'} || {}
l!l
275
MC/DC100%1/1
$interface_field->{'args'} || {}
$interface_field->{'args'}
Truth table100%2/2
A
A= $interface_field->{'args'}
Aresult
11
00
875 77 ▶ my $object_args = $object_field->{args} || {};
Condition100%2/2
$object_field->{'args'} || {}
l!l
374
MC/DC100%1/1
$object_field->{'args'} || {}
$object_field->{'args'}
Truth table100%2/2
A
A= $object_field->{'args'}
Aresult
11
00
876 77 for my $arg_name (sort keys %$interface_args) {
877 2 my $interface_arg = $interface_args->{$arg_name};
878 2 my $object_arg = $object_args->{$arg_name};
879 2 ▶ if (!$object_arg) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($object_arg) 1 1 2
880 1 push @errors, "Interface field argument "
881 1 . "@{[$interface->name]}.$field_name($arg_name:) expected "
882 1 . "but @{[$object->name]}.$field_name does not provide it.";
883 1 next;
884 }
885 1 ▶ if (ref($interface_arg->{type}) && ref($object_arg->{type})
Branch: 1 branch
BranchTrueFalseTotal
if (ref $interface_arg->{"type"} and ref $object_arg->{"type"} and $interface_arg->{"type"}->to_string ne $object_arg->{"type"}->to_string) 1 0 1
Condition33%2/6
ref $interface_arg->{"type"} and ref $object_arg->{"type"} and $interface_arg->{"type"}->to_string ne $object_arg->{"type"}->to_string
!ll&&!rl&&r
001
ref $interface_arg->{"type"} and ref $object_arg->{"type"}
!ll&&!rl&&r
001
MC/DC0%0/3
ref $interface_arg->{"type"} and ref $object_arg->{"type"} and $interface_arg->{"type"}->to_string ne $object_arg->{"type"}->to_string
ref $interface_arg->{"type"} ref $object_arg->{"type"} $interface_arg->{"type"}->to_string ne $object_arg->{"type"}->to_string
Truth table25%1/4
A and B and C
A= ref $interface_arg->{"type"}B= ref $object_arg->{"type"}C= $interface_arg->{"type"}->to_string ne $object_arg->{"type"}->to_string
ABCresult
0XX0
10X0
1100
1111
886 && $interface_arg->{type}->to_string ne $object_arg->{type}->to_string) {
887 1 push @errors, "Interface field argument "
888 1 . "@{[$interface->name]}.$field_name($arg_name:) expects type "
889 1 . "@{[$interface_arg->{type}->to_string]} but "
890 1 . "@{[$object->name]}.$field_name($arg_name:) is type "
891 1 . "@{[$object_arg->{type}->to_string]}.";
892 }
893 }
894 77 for my $arg_name (sort keys %$object_args) {
895 3 ▶ next if $interface_args->{$arg_name};
Branch: 1 branch
BranchTrueFalseTotal
if $interface_args->{$arg_name} 1 2 3
896 2 my $arg = $object_args->{$arg_name};
897 2 my $arg_type = $arg->{type};
898 2 ▶ if (ref($arg_type) && $arg_type->isa('GraphQL::Houtou::Type::NonNull')
Branch: 1 branch
BranchTrueFalseTotal
if (ref $arg_type and $arg_type->isa("GraphQL::Houtou::Type::NonNull") and not exists $arg->{"default_value"}) 1 1 2
Condition50%3/6
ref $arg_type and $arg_type->isa("GraphQL::Houtou::Type::NonNull") and not exists $arg->{"default_value"}
!ll&&!rl&&r
011
ref $arg_type and $arg_type->isa("GraphQL::Houtou::Type::NonNull")
!ll&&!rl&&r
002
MC/DC33%1/3
ref $arg_type and $arg_type->isa("GraphQL::Houtou::Type::NonNull") and not exists $arg->{"default_value"}
ref $arg_type $arg_type->isa("GraphQL::Houtou::Type::NonNull") not exists $arg->{"default_value"}
Truth table50%2/4
A and B and not(C)
A= ref $arg_typeB= $arg_type->isa("GraphQL::Houtou::Type::NonNull")C= not exists $arg->{"default_value"}
ABCresult
0XX0
10X0
1100
1111
899 && !exists $arg->{default_value}) {
900 1 push @errors, "Object field @{[$object->name]}.$field_name includes required "
901 . "argument $arg_name that is missing from the Interface field "
902 1 . "@{[$interface->name]}.$field_name.";
903 }
904 }
905 }
906  
907 58 return @errors;
908 }
909  
910 # Spec IsValidImplementationFieldType: object field types are covariant
911 # against the interface field type.
912 121 ▶sub _is_sub_type {
Subroutine _is_sub_type: called CC=20 SCAR=38.7
913 121 my ($self, $maybe, $super) = @_;
914 121 ▶ return 0 if !ref($maybe) || !ref($super);
Branch: 1 branch
BranchTrueFalseTotal
unless ref $maybe and ref $super 0 121 121
Condition33%1/3
ref $maybe and ref $super
!ll&&!rl&&r
00121
MC/DC0%0/2
ref $maybe and ref $super
ref $maybe ref $super
Truth table33%1/3
A and B
A= ref $maybeB= ref $super
ABresult
0X0
100
111
915 121 ▶ if ($super->isa('GraphQL::Houtou::Type::NonNull')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($super->isa("GraphQL::Houtou::Type::NonNull")) 33 88 121
916 33 ▶ return 0 if !$maybe->isa('GraphQL::Houtou::Type::NonNull');
Branch: 1 branch
BranchTrueFalseTotal
unless $maybe->isa("GraphQL::Houtou::Type::NonNull") 0 33 33
917 33 return $self->_is_sub_type($maybe->of, $super->of);
918 }
919 88 ▶ return $self->_is_sub_type($maybe->of, $super)
Branch: 1 branch
BranchTrueFalseTotal
if $maybe->isa("GraphQL::Houtou::Type::NonNull") 3 85 88
920 if $maybe->isa('GraphQL::Houtou::Type::NonNull');
921 85 ▶ if ($super->isa('GraphQL::Houtou::Type::List')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($super->isa("GraphQL::Houtou::Type::List")) 8 77 85
922 8 ▶ return 0 if !$maybe->isa('GraphQL::Houtou::Type::List');
Branch: 1 branch
BranchTrueFalseTotal
unless $maybe->isa("GraphQL::Houtou::Type::List") 0 8 8
923 8 return $self->_is_sub_type($maybe->of, $super->of);
924 }
925 77 ▶ return 0 if $maybe->isa('GraphQL::Houtou::Type::List');
Branch: 1 branch
BranchTrueFalseTotal
if $maybe->isa("GraphQL::Houtou::Type::List") 0 77 77
926 77 ▶ return 1 if $maybe->name eq $super->name;
Branch: 1 branch
BranchTrueFalseTotal
if $maybe->name eq $super->name 75 2 77
927 2 ▶ if (_is_object_type($maybe) || _is_interface_type($maybe)) {
Branch: 1 branch
BranchTrueFalseTotal
if (_is_object_type($maybe) or _is_interface_type($maybe)) 1 1 2
Condition66%2/3
_is_object_type($maybe) or _is_interface_type($maybe)
l!l&&r!l&&!r
101
MC/DC50%1/2
_is_object_type($maybe) or _is_interface_type($maybe)
_is_object_type($maybe) _is_interface_type($maybe)
Truth table66%2/3
A or B
A= _is_object_type($maybe)B= _is_interface_type($maybe)
ABresult
1X1
011
000
928 return 1 if _is_interface_type($super)
929 1 ▶ && grep { ref($_) && $_->name eq $super->name } @{ $maybe->interfaces || [] };
Branch: 1 branch
BranchTrueFalseTotal
if _is_interface_type($super) and grep {ref $_ and $_->name eq $super->name;} @{$maybe->interfaces or [];} 1 0 1
Condition37%3/8
_is_interface_type($super) and grep {ref $_ and $_->name eq $super->name;} @{$maybe->interfaces or [];}
!ll&&!rl&&r
001
ref $_ && $_->name eq $super->name
!ll&&!rl&&r
001
$maybe->interfaces || []
l!l
10
MC/DC0%0/2
_is_interface_type($super) and grep {ref $_ and $_->name eq $super->name;} @{$maybe->interfaces or [];}
_is_interface_type($super) grep {ref $_ and $_->name eq $super->name;} @{$maybe->interfaces or [];}
MC/DC0%0/2
ref $_ && $_->name eq $super->name
ref $_ $_->name eq $super->name
MC/DC0%0/1
$maybe->interfaces || []
$maybe->interfaces
Truth table33%1/3
A and B
A= _is_interface_type($super)B= grep {ref $_ and $_->name eq $super->name;} @{$maybe->interfaces or [];}
ABresult
0X0
100
111
Truth table33%1/3
A && B
A= ref $_B= $_->name eq $super->name
ABresult
0X0
100
111
Truth table50%1/2
A
A= $maybe->interfaces
Aresult
11
00
930 return 1 if $super->isa('GraphQL::Houtou::Type::Union')
931 0 ▶ && grep { ref($_) && $_->name eq $maybe->name } @{ $super->types || [] };
Branch: 1 branch
BranchTrueFalseTotal
if $super->isa("GraphQL::Houtou::Type::Union") and grep {ref $_ and $_->name eq $maybe->name;} @{$super->types or [];} 0 0 0
Condition0%0/8
$super->isa("GraphQL::Houtou::Type::Union") and grep {ref $_ and $_->name eq $maybe->name;} @{$super->types or [];}
!ll&&!rl&&r
000
ref $_ && $_->name eq $maybe->name
!ll&&!rl&&r
000
$super->types || []
l!l
00
MC/DC0%0/2
$super->isa("GraphQL::Houtou::Type::Union") and grep {ref $_ and $_->name eq $maybe->name;} @{$super->types or [];}
$super->isa("GraphQL::Houtou::Type::Union") grep {ref $_ and $_->name eq $maybe->name;} @{$super->types or [];}
MC/DC0%0/2
ref $_ && $_->name eq $maybe->name
ref $_ $_->name eq $maybe->name
MC/DC0%0/1
$super->types || []
$super->types
Truth table0%0/3
A and B
A= $super->isa("GraphQL::Houtou::Type::Union")B= grep {ref $_ and $_->name eq $maybe->name;} @{$super->types or [];}
ABresult
0X0
100
111
Truth table0%0/3
A && B
A= ref $_B= $_->name eq $maybe->name
ABresult
0X0
100
111
Truth table0%0/2
A
A= $super->types
Aresult
11
00
932 }
933 1 return 0;
934 }
935  
936 2089 ▶sub _is_object_type {
Subroutine _is_object_type: called CC=3 SCAR=11.4
937 2089 my ($type) = @_;
938 2089 ▶ return ref($type)
Condition66%4/6
ref $type && ($type->isa('GraphQL::Houtou::Type::Object') || $type->isa('GraphQL::Type::Object'))
!ll&&!rl&&r
01287802
$type->isa("GraphQL::Houtou::Type::Object") or $type->isa("GraphQL::Type::Object")
l!l&&r!l&&!r
80201287
MC/DC33%1/3
ref $type && ($type->isa('GraphQL::Houtou::Type::Object') || $type->isa('GraphQL::Type::Object'))
ref $type $type->isa("GraphQL::Houtou::Type::Object") $type->isa("GraphQL::Type::Object")
Truth table50%2/4
A && B or C
A= ref $typeB= $type->isa("GraphQL::Houtou::Type::Object")C= $type->isa("GraphQL::Type::Object")
ABCresult
0XX0
1000
11X1
1011
939 && ($type->isa('GraphQL::Houtou::Type::Object') || $type->isa('GraphQL::Type::Object'));
940 }
941  
942 5006 ▶sub _is_interface_type {
Subroutine _is_interface_type: called CC=3 SCAR=11.4
943 5006 my ($type) = @_;
944 5006 ▶ return ref($type)
Condition66%4/6
ref $type && ($type->isa('GraphQL::Houtou::Type::Interface') || $type->isa('GraphQL::Type::Interface'))
!ll&&!rl&&r
04848158
$type->isa("GraphQL::Houtou::Type::Interface") or $type->isa("GraphQL::Type::Interface")
l!l&&r!l&&!r
15804848
MC/DC33%1/3
ref $type && ($type->isa('GraphQL::Houtou::Type::Interface') || $type->isa('GraphQL::Type::Interface'))
ref $type $type->isa("GraphQL::Houtou::Type::Interface") $type->isa("GraphQL::Type::Interface")
Truth table50%2/4
A && B or C
A= ref $typeB= $type->isa("GraphQL::Houtou::Type::Interface")C= $type->isa("GraphQL::Type::Interface")
ABCresult
0XX0
1000
11X1
1011
945 && ($type->isa('GraphQL::Houtou::Type::Interface') || $type->isa('GraphQL::Type::Interface'));
946 }
947  
948 1263 ▶sub _is_output_type {
Subroutine _is_output_type: called CC=2 SCAR=8.1
949 1263 my ($type) = @_;
950 1263 ▶ return ref($type) && _does_any_role($type, qw(
Condition33%1/3
ref $type && _does_any_role($type, ('GraphQL::Houtou::Role::Output', 'GraphQL::Role::Output'))
!ll&&!rl&&r
001263
MC/DC0%0/2
ref $type && _does_any_role($type, ('GraphQL::Houtou::Role::Output', 'GraphQL::Role::Output'))
ref $type _does_any_role($type, ('GraphQL::Houtou::Role::Output', 'GraphQL::Role::Output'))
Truth table33%1/3
A && B
A= ref $typeB= _does_any_role($type, ('GraphQL::Houtou::Role::Output', 'GraphQL::Role::Output'))
ABresult
0X0
100
111
951 GraphQL::Houtou::Role::Output
952 GraphQL::Role::Output
953 ));
954 }
955  
956 2007 ▶sub _is_input_type {
Subroutine _is_input_type: called CC=2 SCAR=7.1
957 2007 my ($type) = @_;
958 2007 ▶ return ref($type) && _does_any_role($type, qw(
Condition66%2/3
ref $type && _does_any_role($type, ('GraphQL::Houtou::Role::Input', 'GraphQL::Role::Input'))
!ll&&!rl&&r
01265742
MC/DC50%1/2
ref $type && _does_any_role($type, ('GraphQL::Houtou::Role::Input', 'GraphQL::Role::Input'))
ref $type _does_any_role($type, ('GraphQL::Houtou::Role::Input', 'GraphQL::Role::Input'))
Truth table66%2/3
A && B
A= ref $typeB= _does_any_role($type, ('GraphQL::Houtou::Role::Input', 'GraphQL::Role::Input'))
ABresult
0X0
100
111
959 GraphQL::Houtou::Role::Input
960 GraphQL::Role::Input
961 ));
962 }
963  
964 578 ▶sub build_native_runtime {
Subroutine build_native_runtime: called CC=16 SCAR=27.7
Pod documented
965 578 my ($self, %opts) = @_;
966 578 my $cache_max = delete $opts{program_cache_max};
967 578 my $max_depth = delete $opts{max_depth};
968 578 my $max_nodes = delete $opts{max_nodes};
969 578 my $max_cost = delete $opts{max_cost};
970 578 my $default_list_size = delete $opts{default_list_size};
971 578 my $async = delete $opts{async};
972 578 my $async_adapter = delete $opts{async_adapter};
973 $async_adapter = $self->{_default_async_adapter}
974 578 ▶ if !defined $async_adapter && $self->{_default_async_adapter};
Branch: 1 branch
BranchTrueFalseTotal
if not defined $async_adapter and $self->{"_default_async_adapter"} 1 577 578
Condition100%3/3
not defined $async_adapter and $self->{"_default_async_adapter"}
!ll&&!rl&&r
205571
MC/DC100%2/2
not defined $async_adapter and $self->{"_default_async_adapter"}
not defined $async_adapter $self->{"_default_async_adapter"}
Truth table100%3/3
not(A) and B
A= not defined $async_adapterB= $self->{"_default_async_adapter"}
ABresult
0X0
100
111
975 578 my $validate = delete $opts{validate};
976 578 my $allow_introspection = delete $opts{allow_introspection};
977 578 my %runtime_args;
978 578 ▶ $runtime_args{program_cache_max} = $cache_max if defined $cache_max;
Branch: 1 branch
BranchTrueFalseTotal
if defined $cache_max 31 547 578
979 578 ▶ $runtime_args{max_depth} = $max_depth if defined $max_depth;
Branch: 1 branch
BranchTrueFalseTotal
if defined $max_depth 5 573 578
980 578 ▶ $runtime_args{max_nodes} = $max_nodes if defined $max_nodes;
Branch: 1 branch
BranchTrueFalseTotal
if defined $max_nodes 1 577 578
981 578 ▶ $runtime_args{max_cost} = $max_cost if defined $max_cost;
Branch: 1 branch
BranchTrueFalseTotal
if defined $max_cost 2 576 578
982 578 ▶ $runtime_args{default_list_size} = $default_list_size if defined $default_list_size;
Branch: 1 branch
BranchTrueFalseTotal
if defined $default_list_size 0 578 578
983 578 ▶ $runtime_args{async} = $async if defined $async;
Branch: 1 branch
BranchTrueFalseTotal
if defined $async 91 487 578
984 578 ▶ $runtime_args{async_adapter} = $async_adapter if defined $async_adapter;
Branch: 1 branch
BranchTrueFalseTotal
if defined $async_adapter 21 557 578
985 578 ▶ $runtime_args{validate} = $validate if defined $validate;
Branch: 1 branch
BranchTrueFalseTotal
if defined $validate 6 572 578
986 578 ▶ $runtime_args{allow_introspection} = $allow_introspection
Branch: 1 branch
BranchTrueFalseTotal
if defined $allow_introspection 3 575 578
987 if defined $allow_introspection;
988 578 ▶ if (%opts || %runtime_args) {
Branch: 1 branch
BranchTrueFalseTotal
if (%opts or %runtime_args) 151 427 578
Condition66%2/3
%opts or %runtime_args
l!l&&r!l&&!r
0151427
MC/DC50%1/2
%opts or %runtime_args
%opts %runtime_args
Truth table66%2/3
A or B
A= %optsB= %runtime_args
ABresult
1X1
011
000
989 151 ▶ my $runtime_schema = %opts ? $self->compile_runtime(%opts) : $self->build_runtime;
Branch: 1 branch
BranchTrueFalseTotal
%opts ? : 0 151 151
990 151 require GraphQL::Houtou::Runtime::NativeRuntime;
991 151 return GraphQL::Houtou::Runtime::NativeRuntime->new(
992 runtime_schema => $runtime_schema,
993 %runtime_args,
994 );
995 }
996 427 ▶ return $self->{_compiled_native_runtime} if $self->{_compiled_native_runtime};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"_compiled_native_runtime"} 334 93 427
997 93 require GraphQL::Houtou::Runtime::NativeRuntime;
998 93 return $self->{_compiled_native_runtime} = GraphQL::Houtou::Runtime::NativeRuntime->new(
999 runtime_schema => $self->build_runtime,
1000 );
1001 }
1002  
1003 292 ▶sub build_runtime {
Subroutine build_runtime: called CC=3 SCAR=11.0
Pod undocumented
1004 292 my ($self, %opts) = @_;
1005 292 ▶ return $self->compile_runtime(%opts) if %opts;
Branch: 1 branch
BranchTrueFalseTotal
if %opts 0 292 292
1006 292 ▶ return $self->{_compiled_runtime_graph} if $self->{_compiled_runtime_graph};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"_compiled_runtime_graph"} 93 199 292
1007 199 return $self->{_compiled_runtime_graph} = $self->compile_runtime;
1008 }
1009  
1010 3 ▶sub compile_runtime_descriptor {
Subroutine compile_runtime_descriptor: called CC=1 SCAR=0.0
Pod undocumented
1011 3 my ($self, %opts) = @_;
1012 3 return $self->compile_runtime(%opts)->to_struct;
1013 }
1014  
1015 3 ▶sub compile_native_runtime_descriptor {
Subroutine compile_native_runtime_descriptor: called CC=1 SCAR=0.0
Pod undocumented
1016 3 my ($self, %opts) = @_;
1017 3 return $self->compile_runtime(%opts)->to_native_struct;
1018 }
1019  
1020 2 ▶sub inflate_runtime {
Subroutine inflate_runtime: called CC=1 SCAR=0.0
Pod undocumented
1021 2 my ($self, $descriptor) = @_;
1022 2 return GraphQL::Houtou::Runtime::SchemaGraph->inflate_schema($self, $descriptor);
1023 }
1024  
1025 1 ▶sub dump_runtime_descriptor {
Subroutine dump_runtime_descriptor: called CC=1 SCAR=0.0
Pod undocumented
1026 1 my ($self, $path, %opts) = @_;
1027 1 my $descriptor = $self->compile_runtime_descriptor(%opts);
1028 1 _write_json_descriptor($path, $descriptor);
1029 1 return $descriptor;
1030 }
1031  
1032 2 ▶sub dump_native_runtime_descriptor {
Subroutine dump_native_runtime_descriptor: called CC=1 SCAR=0.0
Pod undocumented
1033 2 my ($self, $path, %opts) = @_;
1034 2 my $descriptor = $self->compile_native_runtime_descriptor(%opts);
1035 2 _write_json_descriptor($path, $descriptor);
1036 2 return $descriptor;
1037 }
1038  
1039 1 ▶sub load_runtime_descriptor {
Subroutine load_runtime_descriptor: called CC=1 SCAR=0.0
Pod undocumented
1040 1 my ($self, $path) = @_;
1041 1 my $descriptor = _read_json_descriptor($path);
1042 1 return $self->inflate_runtime($descriptor);
1043 }
1044  
1045 2 ▶sub load_native_runtime_descriptor {
Subroutine load_native_runtime_descriptor: called CC=1 SCAR=0.0
Pod undocumented
1046 2 my ($self, $path) = @_;
1047 2 return _read_json_descriptor($path);
1048 }
1049  
1050 2 ▶sub compile_program {
Subroutine compile_program: called CC=1 SCAR=0.0
Pod undocumented
1051 2 my ($self, $document, %opts) = @_;
1052 2 my $runtime = $self->build_runtime;
1053 2 return $runtime->compile_program($document, %opts);
1054 }
1055  
1056 6 ▶sub compile_program_descriptor {
Subroutine compile_program_descriptor: called CC=1 SCAR=0.0
Pod undocumented
1057 6 my ($self, $document, %opts) = @_;
1058 6 my $runtime = $self->build_runtime;
1059 6 return $runtime->compile_program_descriptor($document, %opts);
1060 }
1061  
1062 1 ▶sub dump_program_descriptor {
Subroutine dump_program_descriptor: called CC=1 SCAR=0.0
Pod undocumented
1063 1 my ($self, $document, $path, %opts) = @_;
1064 1 my $descriptor = $self->compile_program_descriptor($document, %opts);
1065 1 _write_json_descriptor($path, $descriptor);
1066 1 return $descriptor;
1067 }
1068  
1069 1 ▶sub load_program_descriptor {
Subroutine load_program_descriptor: called CC=1 SCAR=0.0
Pod undocumented
1070 1 my ($self, $path, %opts) = @_;
1071 1 my $descriptor = _read_json_descriptor($path);
1072 1 return $self->inflate_program($descriptor, %opts);
1073 }
1074  
1075 5 ▶sub inflate_program {
Subroutine inflate_program: called CC=1 SCAR=0.0
Pod undocumented
1076 5 my ($self, $descriptor, %opts) = @_;
1077 5 my $runtime = $self->build_runtime;
1078 5 return $runtime->inflate_program($descriptor, %opts);
1079 }
1080  
1081 254 ▶sub execute {
Subroutine execute: called CC=2 SCAR=6.9
Pod undocumented
1082 254 my ($self, $document, %opts) = @_;
1083 die "promise_code is no longer supported; Promise::XS is built in and custom backends use async_adapter.\n"
1084 254 ▶ if exists $opts{promise_code};
Branch: 1 branch
BranchTrueFalseTotal
if exists $opts{"promise_code"} 1 253 254
1085  
1086 253 my $runtime = $self->build_native_runtime;
1087 253 return $runtime->execute_document($document, %opts);
1088 }
1089  
1090 3 ▶sub compile_native_program_descriptor {
Subroutine compile_native_program_descriptor: called CC=1 SCAR=0.0
Pod undocumented
1091 3 my ($self, $document, %opts) = @_;
1092 3 my $runtime = $self->build_native_runtime;
1093 3 return $runtime->compile_program_descriptor_for_document($document, %opts);
1094 }
1095  
1096 1 ▶sub compile_native_program {
Subroutine compile_native_program: called CC=1 SCAR=0.0
Pod undocumented
1097 1 my ($self, $document, %opts) = @_;
1098 1 GraphQL::Houtou::_bootstrap_xs();
1099 1 return GraphQL::Houtou::XS::VM::load_native_program_xs(
1100 $self->compile_native_program_descriptor($document, %opts),
1101 );
1102 }
1103  
1104 7 ▶sub compile_native_bundle_descriptor {
Subroutine compile_native_bundle_descriptor: called CC=1 SCAR=0.0
Pod undocumented
1105 7 my ($self, $document, %opts) = @_;
1106 7 my $runtime = $self->build_native_runtime;
1107 7 return $runtime->compile_bundle_descriptor_for_document($document, %opts);
1108 }
1109  
1110 4 ▶sub compile_native_bundle {
Subroutine compile_native_bundle: called CC=1 SCAR=0.0
Pod undocumented
1111 4 my ($self, $document, %opts) = @_;
1112 4 my $runtime = $self->build_native_runtime;
1113 4 return $runtime->compile_bundle_for_document($document, %opts);
1114 }
1115  
1116 2 ▶sub dump_native_bundle_descriptor {
Subroutine dump_native_bundle_descriptor: called CC=1 SCAR=0.0
Pod undocumented
1117 2 my ($self, $document, $path, %opts) = @_;
1118 2 my $runtime = $self->build_native_runtime;
1119 2 return $runtime->dump_bundle_descriptor_for_document($document, $path, %opts);
1120 }
1121  
1122 1 ▶sub load_native_bundle_descriptor {
Subroutine load_native_bundle_descriptor: called CC=1 SCAR=0.0
Pod undocumented
1123 1 my ($self, $path) = @_;
1124 1 return _read_json_descriptor($path);
1125 }
1126  
1127 0 ▶sub load_native_bundle {
Subroutine load_native_bundle: not called CC=1 SCAR=6.9
Pod undocumented
1128 0 my ($self, $descriptor) = @_;
1129 0 my $runtime = $self->build_native_runtime;
1130 0 return $runtime->load_bundle_descriptor($descriptor);
1131 }
1132  
1133 0 ▶sub load_native_bundle_file {
Subroutine load_native_bundle_file: not called CC=1 SCAR=6.9
Pod undocumented
1134 0 my ($self, $path) = @_;
1135 0 my $runtime = $self->build_native_runtime;
1136 0 return $runtime->load_bundle_descriptor_file($path);
1137 }
1138  
1139 1 ▶sub inflate_native_bundle_descriptor {
Subroutine inflate_native_bundle_descriptor: called CC=1 SCAR=0.0
Pod undocumented
1140 1 my ($self, $descriptor, %opts) = @_;
1141 1 my $runtime = $self->build_native_runtime;
1142 1 return $runtime->inflate_bundle_descriptor($descriptor);
1143 }
1144  
1145 1 ▶sub execute_native_bundle_descriptor {
Subroutine execute_native_bundle_descriptor: called CC=1 SCAR=0.0
Pod undocumented
1146 1 my ($self, $descriptor, %opts) = @_;
1147 1 my $runtime = $self->build_native_runtime;
1148 1 return $runtime->execute_bundle_descriptor($descriptor, %opts);
1149 }
1150  
1151 8 ▶sub execute_native {
Subroutine execute_native: called CC=1 SCAR=0.0
Pod undocumented
1152 8 my ($self, $document, %opts) = @_;
1153 8 my $runtime = $self->build_native_runtime;
1154 8 return $runtime->execute_document($document, %opts, strict_sync => 1);
1155 }
1156  
1157 4 ▶sub runtime_cache {
Subroutine runtime_cache: called CC=1 SCAR=0.0
Pod undocumented
1158 4 my ($self) = @_;
1159 4 return $self->{_runtime_cache};
1160 }
1161  
1162 5 ▶sub clear_runtime_cache {
Subroutine clear_runtime_cache: called CC=1 SCAR=0.0
Pod undocumented
1163 5 my ($self) = @_;
1164 5 delete $self->{_runtime_cache};
1165 5 delete $self->{_compiled_runtime_graph};
1166 5 delete $self->{_compiled_native_runtime};
1167 5 return $self;
1168 }
1169  
1170 214 ▶sub _runtime_cache {
Subroutine _runtime_cache: called CC=34 SCAR=36.0
1171 214 my ($self) = @_;
1172 214 ▶ return $self->{_runtime_cache} if $self->{_runtime_cache};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"_runtime_cache"} 20 194 214
1173  
1174 194 ▶ my $name2type = $self->name2type || {};
Condition50%1/2
$self->name2type || {}
l!l
1940
MC/DC0%0/1
$self->name2type || {}
$self->name2type
Truth table50%1/2
A
A= $self->name2type
Aresult
11
00
1175 194 ▶ my $interface2types = $self->_interface2types || {};
Condition50%1/2
$self->_interface2types || {}
l!l
1940
MC/DC0%0/1
$self->_interface2types || {}
$self->_interface2types
Truth table50%1/2
A
A= $self->_interface2types
Aresult
11
00
1176 194 ▶ my $possible_type_map = { %{ $self->_possible_type_map || {} } };
Condition50%1/2
$self->_possible_type_map || {}
l!l
0194
MC/DC0%0/1
$self->_possible_type_map || {}
$self->_possible_type_map
Truth table50%1/2
A
A= $self->_possible_type_map
Aresult
11
00
1177 194 my %possible_types;
1178 my %field_maps;
1179 194 my %resolve_type_map;
1180 194 my %is_type_of_map;
1181 194 my %tag_resolver_map;
1182 194 my %runtime_tag_map;
1183 194 my %leaf_kind_map;
1184 194 my %enum_values_map;
1185 194 my %serialize_map;
1186  
1187 # Codes shared with the native runtime's leaf result coercion
1188 # (gql_runtime_vm_serialize_leaf_sv): the executor checks resolver
1189 # output against the field's leaf type at completion time.
1190 194 my %BUILTIN_LEAF_KIND = (
1191 Int => 1, Float => 2, String => 3, Boolean => 4, ID => 5,
1192 );
1193  
1194 194 for my $type (values %$name2type) {
1195 3121 ▶ next if !$type;
Branch: 1 branch
BranchTrueFalseTotal
unless $type 0 3121 3121
1196  
1197 3121 my $type_name = $type->name;
1198 3121 ▶ if (defined $BUILTIN_LEAF_KIND{$type_name}
Branch: 3 branches
BranchTrueFalseTotal
if (defined $BUILTIN_LEAF_KIND{$type_name} and $type->isa('GraphQL::Houtou::Type::Scalar')) { } 970 2151 3121
elsif ($type->isa('GraphQL::Houtou::Type::Enum')) { } 402 1749 2151
elsif ($type->isa('GraphQL::Houtou::Type::Scalar')) { } 36 1713 1749
Condition66%2/3
defined $BUILTIN_LEAF_KIND{$type_name} and $type->isa("GraphQL::Houtou::Type::Scalar")
!ll&&!rl&&r
21510970
MC/DC50%1/2
defined $BUILTIN_LEAF_KIND{$type_name} and $type->isa("GraphQL::Houtou::Type::Scalar")
defined $BUILTIN_LEAF_KIND{$type_name} $type->isa("GraphQL::Houtou::Type::Scalar")
Truth table66%2/3
A and B
A= defined $BUILTIN_LEAF_KIND{$type_name}B= $type->isa("GraphQL::Houtou::Type::Scalar")
ABresult
0X0
100
111
1199 && $type->isa('GraphQL::Houtou::Type::Scalar')) {
1200 970 $leaf_kind_map{$type_name} = $BUILTIN_LEAF_KIND{$type_name};
1201 } elsif ($type->isa('GraphQL::Houtou::Type::Enum')) {
1202 # Serialization maps the internal value back to the enum name
1203 # (Enum->perl_to_graphql); with default values this is identity.
1204 402 ▶ my $values = $type->values || {};
Condition50%1/2
$type->values || {}
l!l
4020
MC/DC0%0/1
$type->values || {}
$type->values
Truth table50%1/2
A
A= $type->values
Aresult
11
00
1205 402 $leaf_kind_map{$type_name} = 6;
1206 $enum_values_map{$type_name} = {
1207 402 map { ($values->{$_}{value} => $_) } keys %$values
1208 };
1209 } elsif ($type->isa('GraphQL::Houtou::Type::Scalar')) {
1210 36 $leaf_kind_map{$type_name} = 7;
1211 36 ▶ $serialize_map{$type_name} = $type->serialize if $type->serialize;
Branch: 1 branch
BranchTrueFalseTotal
if $type->serialize 36 0 36
1212 }
1213  
1214 3121 ▶ if (_does_any_role($type, qw(
Branch: 1 branch
BranchTrueFalseTotal
if (_does_any_role($type, ("GraphQL::Houtou::Role::FieldsOutput", "GraphQL::Role::FieldsOutput"))) 1675 1446 3121
1215 GraphQL::Houtou::Role::FieldsOutput
1216 GraphQL::Role::FieldsOutput
1217 ))) {
1218 1675 ▶ $field_maps{ $type->name } = $type->fields || {};
Condition50%1/2
$type->fields || {}
l!l
16750
MC/DC0%0/1
$type->fields || {}
$type->fields
Truth table50%1/2
A
A= $type->fields
Aresult
11
00
1219 }
1220  
1221 3121 ▶ if ($type->isa('GraphQL::Type::Object') || $type->isa('GraphQL::Houtou::Type::Object')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($type->isa("GraphQL::Type::Object") or $type->isa("GraphQL::Houtou::Type::Object")) 1652 1469 3121
Condition66%2/3
$type->isa("GraphQL::Type::Object") or $type->isa("GraphQL::Houtou::Type::Object")
l!l&&r!l&&!r
016521469
MC/DC50%1/2
$type->isa("GraphQL::Type::Object") or $type->isa("GraphQL::Houtou::Type::Object")
$type->isa("GraphQL::Type::Object") $type->isa("GraphQL::Houtou::Type::Object")
Truth table66%2/3
A or B
A= $type->isa("GraphQL::Type::Object")B= $type->isa("GraphQL::Houtou::Type::Object")
ABresult
1X1
011
000
1222 1652 my $is_type_of = $type->is_type_of;
1223 1652 ▶ $is_type_of_map{ $type->name } = $is_type_of if $is_type_of;
Branch: 1 branch
BranchTrueFalseTotal
if $is_type_of 3 1649 1652
1224 }
1225  
1226 3121 ▶ if ($type->isa('GraphQL::Type::Union') || $type->isa('GraphQL::Houtou::Type::Union')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($type->isa("GraphQL::Type::Union") or $type->isa("GraphQL::Houtou::Type::Union")) 18 3103 3121
Condition66%2/3
$type->isa("GraphQL::Type::Union") or $type->isa("GraphQL::Houtou::Type::Union")
l!l&&r!l&&!r
0183103
MC/DC50%1/2
$type->isa("GraphQL::Type::Union") or $type->isa("GraphQL::Houtou::Type::Union")
$type->isa("GraphQL::Type::Union") $type->isa("GraphQL::Houtou::Type::Union")
Truth table66%2/3
A or B
A= $type->isa("GraphQL::Type::Union")B= $type->isa("GraphQL::Houtou::Type::Union")
ABresult
1X1
011
000
1227 18 ▶ my $types = $type->types || [];
Condition50%1/2
$type->types || []
l!l
180
MC/DC0%0/1
$type->types || []
$type->types
Truth table50%1/2
A
A= $type->types
Aresult
11
00
1228 18 my $resolve_type = $type->resolve_type;
1229 18 ▶ my $tag_resolver = $type->can('tag_resolver') ? $type->tag_resolver : undef;
Branch: 1 branch
BranchTrueFalseTotal
$type->can('tag_resolver') ? : 18 0 18
1230 18 ▶ $resolve_type_map{ $type->name } = $resolve_type if $resolve_type;
Branch: 1 branch
BranchTrueFalseTotal
if $resolve_type 8 10 18
1231 18 ▶ $tag_resolver_map{ $type->name } = $tag_resolver if $tag_resolver;
Branch: 1 branch
BranchTrueFalseTotal
if $tag_resolver 13 5 18
1232 18 $possible_types{ $type->name } = [ @$types ];
1233 18 ▶ $possible_type_map->{ $type->name } ||= { map { ($_->name => 1) } @$types };
Condition50%1/2
$$possible_type_map{$type->name} ||= {map({$_->name, 1;} @$types)}
l!l
018
MC/DC0%0/1
$$possible_type_map{$type->name} ||= {map({$_->name, 1;} @$types)}
$$possible_type_map{$type->name}
Truth table50%1/2
A
A= $$possible_type_map{$type->name}
Aresult
11
00
1234 18 ▶ if (my $tag_map = _build_runtime_tag_map($type, $types, $name2type)) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $tag_map = _build_runtime_tag_map($type, $types, $name2type)) 13 5 18
1235 13 $runtime_tag_map{ $type->name } = $tag_map;
1236 }
1237 18 next;
1238 }
1239  
1240 3103 ▶ if ($type->isa('GraphQL::Type::Interface') || $type->isa('GraphQL::Houtou::Type::Interface')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($type->isa("GraphQL::Type::Interface") or $type->isa("GraphQL::Houtou::Type::Interface")) 23 3080 3103
Condition66%2/3
$type->isa("GraphQL::Type::Interface") or $type->isa("GraphQL::Houtou::Type::Interface")
l!l&&r!l&&!r
0233080
MC/DC50%1/2
$type->isa("GraphQL::Type::Interface") or $type->isa("GraphQL::Houtou::Type::Interface")
$type->isa("GraphQL::Type::Interface") $type->isa("GraphQL::Houtou::Type::Interface")
Truth table66%2/3
A or B
A= $type->isa("GraphQL::Type::Interface")B= $type->isa("GraphQL::Houtou::Type::Interface")
ABresult
1X1
011
000
1241 23 ▶ my $types = [ @{ $interface2types->{ $type->name } || [] } ];
Condition100%2/2
$$interface2types{$type->name} || []
l!l
221
MC/DC100%1/1
$$interface2types{$type->name} || []
$$interface2types{$type->name}
Truth table100%2/2
A
A= $$interface2types{$type->name}
Aresult
11
00
1242 23 my $resolve_type = $type->resolve_type;
1243 23 ▶ my $tag_resolver = $type->can('tag_resolver') ? $type->tag_resolver : undef;
Branch: 1 branch
BranchTrueFalseTotal
$type->can('tag_resolver') ? : 23 0 23
1244 23 ▶ $resolve_type_map{ $type->name } = $resolve_type if $resolve_type;
Branch: 1 branch
BranchTrueFalseTotal
if $resolve_type 6 17 23
1245 23 ▶ $tag_resolver_map{ $type->name } = $tag_resolver if $tag_resolver;
Branch: 1 branch
BranchTrueFalseTotal
if $tag_resolver 16 7 23
1246 23 $possible_types{ $type->name } = $types;
1247 23 ▶ $possible_type_map->{ $type->name } ||= { map { ($_->name => 1) } @$types };
Condition50%1/2
$$possible_type_map{$type->name} ||= {map({$_->name, 1;} @$types)}
l!l
023
MC/DC0%0/1
$$possible_type_map{$type->name} ||= {map({$_->name, 1;} @$types)}
$$possible_type_map{$type->name}
Truth table50%1/2
A
A= $$possible_type_map{$type->name}
Aresult
11
00
1248 23 ▶ if (my $tag_map = _build_runtime_tag_map($type, $types, $name2type)) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $tag_map = _build_runtime_tag_map($type, $types, $name2type)) 15 8 23
1249 15 $runtime_tag_map{ $type->name } = $tag_map;
1250 }
1251 23 next;
1252 }
1253 }
1254  
1255 return $self->{_runtime_cache} = {
1256 root_types => {
1257 query => $self->{query},
1258 mutation => $self->{mutation},
1259 subscription => $self->{subscription},
1260 },
1261 194 name2type => $name2type,
1262 interface2types => $interface2types,
1263 possible_type_map => $possible_type_map,
1264 possible_types => \%possible_types,
1265 field_maps => \%field_maps,
1266 resolve_type_map => \%resolve_type_map,
1267 is_type_of_map => \%is_type_of_map,
1268 tag_resolver_map => \%tag_resolver_map,
1269 runtime_tag_map => \%runtime_tag_map,
1270 leaf_kind_map => \%leaf_kind_map,
1271 enum_values_map => \%enum_values_map,
1272 serialize_map => \%serialize_map,
1273 };
1274 }
1275  
1276 41 ▶sub _build_runtime_tag_map {
Subroutine _build_runtime_tag_map: called CC=16 SCAR=39.1
1277 41 my ($abstract_type, $possible_types, $name2type) = @_;
1278 41 my %tag_map;
1279 41 ▶ my $declared = $abstract_type->can('tag_map') ? $abstract_type->tag_map : undef;
Branch: 1 branch
BranchTrueFalseTotal
$abstract_type->can('tag_map') ? : 41 0 41
1280  
1281 41 ▶ if ($declared) {
Branch: 1 branch
BranchTrueFalseTotal
if ($declared) 0 41 41
1282 0 for my $tag (keys %$declared) {
1283 0 my $target = $declared->{$tag};
1284 0 ▶ my $type = ref($target) ? $target : $name2type->{$target};
Branch: 1 branch
BranchTrueFalseTotal
ref $target ? : 0 0 0
1285 0 ▶ next if !$type;
Branch: 1 branch
BranchTrueFalseTotal
unless $type 0 0 0
1286 0 ▶ next if !($type->isa('GraphQL::Type::Object') || $type->isa('GraphQL::Houtou::Type::Object'));
Branch: 1 branch
BranchTrueFalseTotal
unless $type->isa("GraphQL::Type::Object") or $type->isa("GraphQL::Houtou::Type::Object") 0 0 0
Condition0%0/3
$type->isa("GraphQL::Type::Object") or $type->isa("GraphQL::Houtou::Type::Object")
l!l&&r!l&&!r
000
MC/DC0%0/2
$type->isa("GraphQL::Type::Object") or $type->isa("GraphQL::Houtou::Type::Object")
$type->isa("GraphQL::Type::Object") $type->isa("GraphQL::Houtou::Type::Object")
Truth table0%0/3
A or B
A= $type->isa("GraphQL::Type::Object")B= $type->isa("GraphQL::Houtou::Type::Object")
ABresult
1X1
011
000
1287 0 $tag_map{$tag} = $type;
1288 }
1289 }
1290  
1291 41 ▶ for my $type (@{ $possible_types || [] }) {
Condition50%1/2
$possible_types || []
l!l
410
MC/DC0%0/1
$possible_types || []
$possible_types
Truth table50%1/2
A
A= $possible_types
Aresult
11
00
1292 59 ▶ next if !$type || !$type->can('runtime_tag');
Branch: 1 branch
BranchTrueFalseTotal
unless $type and $type->can("runtime_tag") 0 59 59
Condition33%1/3
$type and $type->can("runtime_tag")
!ll&&!rl&&r
0059
MC/DC0%0/2
$type and $type->can("runtime_tag")
$type $type->can("runtime_tag")
Truth table33%1/3
A and B
A= $typeB= $type->can("runtime_tag")
ABresult
0X0
100
111
1293 59 my $tag = $type->runtime_tag;
1294 59 ▶ next if !defined $tag || ref($tag);
Branch: 1 branch
BranchTrueFalseTotal
if not defined $tag or ref $tag 14 45 59
Condition66%2/3
not defined $tag or ref $tag
l!l&&r!l&&!r
14045
MC/DC50%1/2
not defined $tag or ref $tag
not defined $tag ref $tag
Truth table66%2/3
not(A) or B
A= not defined $tagB= ref $tag
ABresult
1X1
011
000
1295 45 ▶ $tag_map{$tag} ||= $type;
Condition33%1/3
$tag_map{$tag} ||= $type
l!l&&r!l&&!r
0450
MC/DC0%0/2
$tag_map{$tag} ||= $type
$tag_map{$tag} $type
Truth table33%1/3
A ||= B
A= $tag_map{$tag}B= $type
ABresult
1X1
011
000
1296 }
1297  
1298 41 ▶ return keys(%tag_map) ? \%tag_map : undef;
Branch: 1 branch
BranchTrueFalseTotal
keys %tag_map ? : 28 13 41
1299 }
1300  
1301 249 ▶sub _build_name2type {
Subroutine _build_name2type: called CC=5 SCAR=16.2
1302 249 my ($self) = @_;
1303 249 my @types = grep $_, (map $self->$_, qw(query mutation subscription)), $SCHEMA_META_TYPE;
1304 249 ▶ push @types, @{ $self->types || [] };
Condition50%1/2
$self->types || []
l!l
2490
MC/DC0%0/1
$self->types || []
$self->types
Truth table50%1/2
A
A= $self->types
Aresult
11
00
1305  
1306 249 my %name2type;
1307 249 _expand_type_houtou(\%name2type, $_) for @types;
1308 # The built-in scalars are always available (spec 3.5) even when nothing
1309 # in the schema references them, e.g. a variable declared as Int against
1310 # a schema whose fields are all String.
1311 247 for my $builtin (
1312 $GraphQL::Houtou::Type::Scalar::Int,
1313 $GraphQL::Houtou::Type::Scalar::Float,
1314 $GraphQL::Houtou::Type::Scalar::String,
1315 $GraphQL::Houtou::Type::Scalar::Boolean,
1316 $GraphQL::Houtou::Type::Scalar::ID,
1317 ) {
1318 1235 ▶ $name2type{ $builtin->name } //= $builtin;
Condition66%2/3
$name2type{$builtin->name} //= $builtin
l!l&&r!l&&!r
11151200
MC/DC0%0/2
$name2type{$builtin->name} //= $builtin
$name2type{$builtin->name} $builtin
Truth table66%2/3
A //= B
A= $name2type{$builtin->name}B= $builtin
ABresult
1X1
011
000
1319 }
1320 247 return \%name2type;
1321 }
1322  
1323 4 ▶sub _write_json_descriptor {
Subroutine _write_json_descriptor: called CC=3 SCAR=11.2
1324 4 my ($path, $descriptor) = @_;
1325 4 ▶ open my $fh, '>', $path or die "Cannot write descriptor '$path': $!";
Branch: 1 branch
BranchTrueFalseTotal
open my $fh, ">", $path or die "Cannot write descriptor '${path}': $!" 4 0 4
1326 4 print {$fh} $JSON->encode($descriptor);
1327 4 ▶ close $fh or die "Cannot close descriptor '$path': $!";
Branch: 1 branch
BranchTrueFalseTotal
close $fh or die "Cannot close descriptor '${path}': $!" 4 0 4
1328 4 return;
1329 }
1330  
1331 5 ▶sub _read_json_descriptor {
Subroutine _read_json_descriptor: called CC=3 SCAR=11.2
1332 5 my ($path) = @_;
1333 5 ▶ open my $fh, '<', $path or die "Cannot read descriptor '$path': $!";
Branch: 1 branch
BranchTrueFalseTotal
open my $fh, "<", $path or die "Cannot read descriptor '${path}': $!" 5 0 5
1334 5 local $/;
1335 5 my $json = <$fh>;
1336 5 ▶ close $fh or die "Cannot close descriptor '$path': $!";
Branch: 1 branch
BranchTrueFalseTotal
close $fh or die "Cannot close descriptor '${path}': $!" 5 0 5
1337 5 return $JSON->decode($json);
1338 }
1339  
1340 10285 ▶sub _does_any_role {
Subroutine _does_any_role: called CC=3 SCAR=12.0
1341 10285 my ($type, @roles) = @_;
1342 10285 ▶ return if !$type || !$type->can('DOES');
Branch: 1 branch
BranchTrueFalseTotal
unless $type and $type->can("DOES") 0 10285 10285
Condition33%1/3
$type and $type->can("DOES")
!ll&&!rl&&r
0010285
MC/DC0%0/2
$type and $type->can("DOES")
$type $type->can("DOES")
Truth table33%1/3
A and B
A= $typeB= $type->can("DOES")
ABresult
0X0
100
111
1343 10285 return !!grep { $type->DOES($_) } @roles;
1344 }
1345  
1346 175 ▶sub _build_name2directive {
Subroutine _build_name2directive: called CC=2 SCAR=7.0
1347 175 my ($self) = @_;
1348 175 ▶ return +{ map { ($_->name => $_) } @{ $self->directives || [] } };
Condition50%1/2
$self->directives || []
l!l
1750
MC/DC0%0/1
$self->directives || []
$self->directives
Truth table50%1/2
A
A= $self->directives
Aresult
11
00
1349 }
1350  
1351 189 ▶sub _build__interface2types {
Subroutine _build__interface2types: called CC=10 SCAR=23.4
1352 189 my ($self) = @_;
1353 189 ▶ my $name2type = $self->name2type || {};
Condition50%1/2
$self->name2type || {}
l!l
1890
MC/DC0%0/1
$self->name2type || {}
$self->name2type
Truth table50%1/2
A
A= $self->name2type
Aresult
11
00
1354 189 my %interface2types;
1355  
1356 189 for my $type (values %$name2type) {
1357 3041 ▶ next if !($type->isa('GraphQL::Type::Object') || $type->isa('GraphQL::Houtou::Type::Object'));
Branch: 1 branch
BranchTrueFalseTotal
unless $type->isa("GraphQL::Type::Object") or $type->isa("GraphQL::Houtou::Type::Object") 1426 1615 3041
Condition66%2/3
$type->isa("GraphQL::Type::Object") or $type->isa("GraphQL::Houtou::Type::Object")
l!l&&r!l&&!r
016151426
MC/DC50%1/2
$type->isa("GraphQL::Type::Object") or $type->isa("GraphQL::Houtou::Type::Object")
$type->isa("GraphQL::Type::Object") $type->isa("GraphQL::Houtou::Type::Object")
Truth table66%2/3
A or B
A= $type->isa("GraphQL::Type::Object")B= $type->isa("GraphQL::Houtou::Type::Object")
ABresult
1X1
011
000
1358 1615 ▶ my @queue = @{ $type->interfaces || [] };
Condition50%1/2
$type->interfaces || []
l!l
16150
MC/DC0%0/1
$type->interfaces || []
$type->interfaces
Truth table50%1/2
A
A= $type->interfaces
Aresult
11
00
1359 1615 my %seen;
1360 1615 ▶ while (my $interface = shift @queue) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $interface = shift @queue) 34 1615 1649
1361 34 ▶ next if !$interface || $seen{ $interface->name }++;
Branch: 1 branch
BranchTrueFalseTotal
if not $interface or $seen{$interface->name}++ 1 33 34
Condition66%2/3
not $interface or $seen{$interface->name}++
l!l&&r!l&&!r
0133
MC/DC50%1/2
not $interface or $seen{$interface->name}++
not $interface $seen{$interface->name}++
Truth table66%2/3
not(A) or B
A= not $interfaceB= $seen{$interface->name}++
ABresult
1X1
011
000
1362 33 push @{ $interface2types{ $interface->name } }, $type;
1363 33 ▶ push @queue, @{ $interface->can('interfaces') ? $interface->interfaces : [] };
Branch: 1 branch
BranchTrueFalseTotal
$interface->can('interfaces') ? : 33 0 33
1364 }
1365 }
1366  
1367 189 return \%interface2types;
1368 }
1369  
1370 297 ▶sub get_possible_types {
Subroutine get_possible_types: called CC=4 SCAR=13.9
Pod undocumented
1371 297 my ($self, $abstract_type) = @_;
1372 297 ▶ return $abstract_type->get_types
Branch: 1 branch
BranchTrueFalseTotal
if $abstract_type->isa("GraphQL::Type::Union") or $abstract_type->isa("GraphQL::Houtou::Type::Union") 91 206 297
Condition66%2/3
$abstract_type->isa("GraphQL::Type::Union") or $abstract_type->isa("GraphQL::Houtou::Type::Union")
l!l&&r!l&&!r
091206
MC/DC50%1/2
$abstract_type->isa("GraphQL::Type::Union") or $abstract_type->isa("GraphQL::Houtou::Type::Union")
$abstract_type->isa("GraphQL::Type::Union") $abstract_type->isa("GraphQL::Houtou::Type::Union")
Truth table66%2/3
A or B
A= $abstract_type->isa("GraphQL::Type::Union")B= $abstract_type->isa("GraphQL::Houtou::Type::Union")
ABresult
1X1
011
000
1373 if $abstract_type->isa('GraphQL::Type::Union') || $abstract_type->isa('GraphQL::Houtou::Type::Union');
1374 206 ▶ return $self->_interface2types->{ $abstract_type->name } || [];
Condition100%2/2
$self->_interface2types->{$abstract_type->name} || []
l!l
17432
MC/DC100%1/1
$self->_interface2types->{$abstract_type->name} || []
$self->_interface2types->{$abstract_type->name}
Truth table100%2/2
A
A= $self->_interface2types->{$abstract_type->name}
Aresult
11
00
1375 }
1376  
1377 0 ▶sub is_possible_type {
Subroutine is_possible_type: not called CC=6 SCAR=37.4
Pod undocumented
1378 0 my ($self, $abstract_type, $possible_type) = @_;
1379 0 ▶ my $map = $self->_possible_type_map || {};
Condition0%0/2
$self->_possible_type_map || {}
l!l
00
MC/DC0%0/1
$self->_possible_type_map || {}
$self->_possible_type_map
Truth table0%0/2
A
A= $self->_possible_type_map
Aresult
11
00
1380 0 my @possibles;
1381  
1382 return $map->{$abstract_type->name}{$possible_type->name}
1383 0 ▶ if $map->{$abstract_type->name};
Branch: 1 branch
BranchTrueFalseTotal
if $$map{$abstract_type->name} 0 0 0
1384  
1385 0 ▶ @possibles = @{ $self->get_possible_types($abstract_type) || [] };
Condition0%0/2
$self->get_possible_types($abstract_type) || []
l!l
00
MC/DC0%0/1
$self->get_possible_types($abstract_type) || []
$self->get_possible_types($abstract_type)
Truth table0%0/2
A
A= $self->get_possible_types($abstract_type)
Aresult
11
00
1386 0 ▶ die <<"EOF" if !@possibles;
Branch: 1 branch
BranchTrueFalseTotal
unless @possibles 0 0 0
1387 0 Could not find possible implementing types for @{[$abstract_type->name]}
1388 in schema. Check that schema.types is defined and is an array of
1389 all possible types in the schema.
1390 EOF
1391 0 $map->{$abstract_type->name} = { map { ($_->name => 1) } @possibles };
1392 0 $self->_possible_type_map($map);
1393 0 ▶ if ($self->{_runtime_cache}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"_runtime_cache"}) 0 0 0
1394 0 $self->{_runtime_cache}{possible_type_map} = $map;
1395 }
1396 0 return $map->{$abstract_type->name}{$possible_type->name};
1397 }
1398  
1399 24487 ▶sub _expand_type_houtou {
Subroutine _expand_type_houtou: called CC=16 SCAR=29.2
1400 24487 my ($map, $type) = @_;
1401 24487 my @types;
1402 my $name;
1403  
1404 24487 ▶ if ($type->can('of')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($type->can("of")) 9785 14702 24487
1405 9785 return _expand_type_houtou($map, $type->of);
1406 }
1407  
1408 14702 ▶ $name = $type->name if $type->can('name');
Branch: 1 branch
BranchTrueFalseTotal
if $type->can("name") 14702 0 14702
1409 14702 ▶ if ($name && $map->{$name}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($name and $map->{$name}) 10807 3895 14702
Condition66%2/3
$name and $map->{$name}
!ll&&!rl&&r
0389510807
MC/DC50%1/2
$name and $map->{$name}
$name $map->{$name}
Truth table66%2/3
A and B
A= $nameB= $map->{$name}
ABresult
0X0
100
111
1410 return []
1411 10807 ▶ if $map->{$name} == $type;
Branch: 1 branch
BranchTrueFalseTotal
if $map->{$name} == $type 10807 0 10807
1412 return []
1413 0 ▶ if _is_builtin_scalar_pair($map->{$name}, $type);
Branch: 1 branch
BranchTrueFalseTotal
if _is_builtin_scalar_pair($map->{$name}, $type) 0 0 0
1414 0 die "Duplicate type $name";
1415 }
1416  
1417 3895 ▶ $map->{$name} = $type if $name;
Branch: 1 branch
BranchTrueFalseTotal
if $name 3895 0 3895
1418  
1419 3895 ▶ push @types, ($type, map @{ _expand_type_houtou($map, $_) }, @{ $type->interfaces || [] })
Branch: 1 branch
BranchTrueFalseTotal
if $type->isa("GraphQL::Type::Object") or $type->isa("GraphQL::Houtou::Type::Object") 2100 1795 3895
Condition60%3/5
$type->isa("GraphQL::Type::Object") or $type->isa("GraphQL::Houtou::Type::Object")
l!l&&r!l&&!r
021001795
$type->interfaces || []
l!l
21000
MC/DC50%1/2
$type->isa("GraphQL::Type::Object") or $type->isa("GraphQL::Houtou::Type::Object")
$type->isa("GraphQL::Type::Object") $type->isa("GraphQL::Houtou::Type::Object")
MC/DC0%0/1
$type->interfaces || []
$type->interfaces
Truth table66%2/3
A or B
A= $type->isa("GraphQL::Type::Object")B= $type->isa("GraphQL::Houtou::Type::Object")
ABresult
1X1
011
000
Truth table50%1/2
A
A= $type->interfaces
Aresult
11
00
1420 if $type->isa('GraphQL::Type::Object') || $type->isa('GraphQL::Houtou::Type::Object');
1421 3895 ▶ push @types, ($type, map @{ _expand_type_houtou($map, $_) }, @{ $type->get_types })
Branch: 1 branch
BranchTrueFalseTotal
if $type->isa("GraphQL::Type::Union") or $type->isa("GraphQL::Houtou::Type::Union") 24 3871 3895
Condition66%2/3
$type->isa("GraphQL::Type::Union") or $type->isa("GraphQL::Houtou::Type::Union")
l!l&&r!l&&!r
0243871
MC/DC50%1/2
$type->isa("GraphQL::Type::Union") or $type->isa("GraphQL::Houtou::Type::Union")
$type->isa("GraphQL::Type::Union") $type->isa("GraphQL::Houtou::Type::Union")
Truth table66%2/3
A or B
A= $type->isa("GraphQL::Type::Union")B= $type->isa("GraphQL::Houtou::Type::Union")
ABresult
1X1
011
000
1422 if $type->isa('GraphQL::Type::Union') || $type->isa('GraphQL::Houtou::Type::Union');
1423 3894 ▶ if (_does_any_role($type, qw(
Branch: 1 branch
BranchTrueFalseTotal
if (_does_any_role($type, ("GraphQL::Houtou::Role::FieldsInput", "GraphQL::Houtou::Role::FieldsOutput", "GraphQL::Role::FieldsInput", "GraphQL::Role::FieldsOutput"))) 2184 1710 3894
1424 GraphQL::Houtou::Role::FieldsInput
1425 GraphQL::Houtou::Role::FieldsOutput
1426 GraphQL::Role::FieldsInput
1427 GraphQL::Role::FieldsOutput
1428 ))) {
1429 2184 ▶ my $fields = $type->fields || {};
Condition50%1/2
$type->fields || {}
l!l
21830
MC/DC0%0/1
$type->fields || {}
$type->fields
Truth table50%1/2
A
A= $type->fields
Aresult
11
00
1430 push @types, map {
1431 2183 ▶ map @{ _expand_type_houtou($map, $_->{type}) }, $_, values %{ $_->{args} || {} }
Condition100%2/2
$_->{'args'} || {}
l!l
15149503
MC/DC100%1/1
$_->{'args'} || {}
$_->{'args'}
Truth table100%2/2
A
A= $_->{'args'}
Aresult
11
00
1432 } values %$fields;
1433 }
1434  
1435 3892 return \@types;
1436 }
1437  
1438 0 ▶sub _is_builtin_scalar_pair {
Subroutine _is_builtin_scalar_pair: not called CC=9 SCAR=45.0
1439 0 my ($left, $right) = @_;
1440 0 ▶ return 0 if !$left || !$right;
Branch: 1 branch
BranchTrueFalseTotal
unless $left and $right 0 0 0
Condition0%0/3
$left and $right
!ll&&!rl&&r
000
MC/DC0%0/2
$left and $right
$left $right
Truth table0%0/3
A and B
A= $leftB= $right
ABresult
0X0
100
111
1441 0 ▶ return 0 if !(
Branch: 1 branch
BranchTrueFalseTotal
unless $left->isa("GraphQL::Type::Scalar") || $left->isa("GraphQL::Houtou::Type::Scalar") and $right->isa("GraphQL::Type::Scalar") || $right->isa("GraphQL::Houtou::Type::Scalar") 0 0 0
Condition0%0/9
$left->isa("GraphQL::Type::Scalar") || $left->isa("GraphQL::Houtou::Type::Scalar") and $right->isa("GraphQL::Type::Scalar") || $right->isa("GraphQL::Houtou::Type::Scalar")
!ll&&!rl&&r
000
$left->isa("GraphQL::Type::Scalar") or $left->isa("GraphQL::Houtou::Type::Scalar")
l!l&&r!l&&!r
000
$right->isa("GraphQL::Type::Scalar") or $right->isa("GraphQL::Houtou::Type::Scalar")
l!l&&r!l&&!r
000
MC/DC0%0/4
$left->isa("GraphQL::Type::Scalar") || $left->isa("GraphQL::Houtou::Type::Scalar") and $right->isa("GraphQL::Type::Scalar") || $right->isa("GraphQL::Houtou::Type::Scalar")
$left->isa("GraphQL::Type::Scalar") $left->isa("GraphQL::Houtou::Type::Scalar") $right->isa("GraphQL::Type::Scalar") $right->isa("GraphQL::Houtou::Type::Scalar")
Truth table0%0/7
A or B and C or D
A= $left->isa("GraphQL::Type::Scalar")B= $left->isa("GraphQL::Houtou::Type::Scalar")C= $right->isa("GraphQL::Type::Scalar")D= $right->isa("GraphQL::Houtou::Type::Scalar")
ABCDresult
00XX0
1X000
01000
1X1X1
1X011
011X1
01011
1442 ($left->isa('GraphQL::Type::Scalar') || $left->isa('GraphQL::Houtou::Type::Scalar'))
1443 && ($right->isa('GraphQL::Type::Scalar') || $right->isa('GraphQL::Houtou::Type::Scalar'))
1444 );
1445 0 ▶ return 0 if !(grep { $_ eq $left->name } qw(Int Float String Boolean ID));
Branch: 1 branch
BranchTrueFalseTotal
unless grep {$_ eq $left->name;} "Int", "Float", "String", "Boolean", "ID" 0 0 0
1446 0 ▶ return $left->name eq $right->name ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$left->name eq $right->name ? : 0 0 0
1447 }
1448  
1449 3675 ▶sub lookup_type {
Subroutine lookup_type: called CC=7 SCAR=20.1
Pod undocumented
1450 3675 my ($typedef, $name2type) = @_;
1451 3675 my ($type, $wrapper_type, $wrapped);
1452  
1453 3675 ▶ die "lookup_type expects a type definition hash reference\n"
Branch: 1 branch
BranchTrueFalseTotal
if ref $typedef ne "HASH" 0 3675 3675
1454 if ref($typedef) ne 'HASH';
1455 3675 ▶ die "lookup_type expects a name2type hash reference\n"
Branch: 1 branch
BranchTrueFalseTotal
if ref $name2type ne "HASH" 0 3675 3675
1456 if ref($name2type) ne 'HASH';
1457  
1458 3675 $type = $typedef->{type};
1459 3675 ▶ die "Undefined type given\n" if !defined $type;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $type 0 3675 3675
1460  
1461 3675 ▶ if (!ref($type)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $type) 2858 817 3675
1462 2858 ▶ return $name2type->{$type} // die "Unknown type '$type'.\n";
Condition100%2/2
$name2type->{$type} // die("Unknown type '${type}'.\n")
l!l
28571
MC/DC100%1/1
$name2type->{$type} // die("Unknown type '${type}'.\n")
$name2type->{$type}
Truth table100%2/2
A
A= $name2type->{$type}
Aresult
11
00
1463 }
1464  
1465 817 ▶ if (ref($type) ne 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $type ne "ARRAY") 0 817 817
1466 0 die "Unknown wrapped type representation\n";
1467 }
1468  
1469 817 ($wrapper_type, $wrapped) = @$type;
1470 817 return lookup_type($wrapped, $name2type)->$wrapper_type;
1471 }
1472  
1473 62 1;
1474 __END__
« blib/lib/GraphQL/Houtou/Type/Interface.pm ↑ Summary blib/lib/GraphQL/Houtou/Runtime/VMBlock.pm »