blib/lib/GraphQL/Houtou.pm

filter: Statementstmt 96.5% 84 / 87 Branchbran 71.4% 20 / 28 Conditioncond 37.5% 3 / 8 MC/DCmcdc 20.0% 1 / 5 Subroutinesub 100% 21 / 21 Podpod 7.1% 1 / 14 totaltotal 79.7% 130 / 163 CC 19 SCAR 20.3
CC
19
Cov
87%
execute
18.2
parse_with_options
4.0
_bootstrap_xs
2.0
CRAP 7.6
« blib/lib/GraphQL/Houtou/Async/Adapter.pm ↑ Summary blib/lib/GraphQL/Houtou/Type/List.pm »
1 package GraphQL::Houtou;
2  
3 93 ▶use 5.014;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 93 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 93 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 93 ▶use Exporter 'import';
Subroutine BEGIN: called CC=1 SCAR=0.0
7 93 ▶use XSLoader ();
Subroutine BEGIN: called CC=1 SCAR=0.0
8 93 ▶use GraphQL::Houtou::Runtime::LazyInfo ();
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 93 our $VERSION = '0.08';
11 93 our $XS_BUNDLE_LOADED = 0;
12 93 our @EXPORT_OK = qw(
13 parse
14 parse_with_options
15 build_schema
16 print_schema
17 execute
18 execute_native
19 execute_to_json
20 compile_runtime
21 build_runtime
22 build_native_runtime
23 compile_native_program
24 compile_native_bundle
25 compile_native_bundle_descriptor
26 build_subgraph_schema
27 );
28  
29 5383 ▶sub _bootstrap_xs {
Subroutine _bootstrap_xs: called CC=2 SCAR=6.9
30 5383 ▶ return 1 if $XS_BUNDLE_LOADED++;
Branch: 1 branch
BranchTrueFalseTotal
if $GraphQL::Houtou::XS_BUNDLE_LOADED++ 5297 86 5383
31 86 XSLoader::load('GraphQL::Houtou', $VERSION);
32 86 return 1;
33 }
34  
35 954 ▶sub parse {
Subroutine parse: called CC=1 SCAR=0.0
Pod undocumented
36 954 my ($source) = @_;
37 954 require GraphQL::Houtou::XS::Parser;
38 954 return GraphQL::Houtou::XS::Parser::parse_xs($source, undef);
39 }
40  
41 3 ▶sub parse_with_options {
Subroutine parse_with_options: called CC=4 SCAR=13.9
Pod undocumented
42 3 my ($source, $options) = @_;
43 3 ▶ $options ||= {};
Condition50%1/2
$options ||= {}
l!l
30
MC/DC0%0/1
$options ||= {}
$options
Truth table50%1/2
A
A= $options
Aresult
11
00
44 3 for my $key (keys %{$options}) {
45 3 ▶ next if $key eq 'no_location';
Branch: 1 branch
BranchTrueFalseTotal
if $key eq "no_location" 1 2 3
46 2 die "Unknown parser option '$key'.\n";
47 }
48 1 my $no_location = $options->{no_location};
49 1 require GraphQL::Houtou::XS::Parser;
50 1 return GraphQL::Houtou::XS::Parser::parse_xs($source, $no_location);
51 }
52  
53 28 ▶sub build_schema {
Subroutine build_schema: called CC=1 SCAR=0.0
Pod undocumented
54 28 my ($doc, %opts) = @_;
55 28 require GraphQL::Houtou::Schema;
56 28 return GraphQL::Houtou::Schema->from_doc($doc, %opts);
57 }
58  
59 8 ▶sub build_subgraph_schema {
Subroutine build_subgraph_schema: called CC=1 SCAR=0.0
Pod undocumented
60 8 require GraphQL::Houtou::Federation;
61 8 return GraphQL::Houtou::Federation::build_subgraph_schema(@_);
62 }
63  
64 6 ▶sub print_schema {
Subroutine print_schema: called CC=1 SCAR=0.0
Pod undocumented
65 6 my ($schema) = @_;
66 6 return $schema->to_doc;
67 }
68  
69 1 ▶sub compile_runtime {
Subroutine compile_runtime: called CC=1 SCAR=0.0
Pod undocumented
70 1 my ($schema, %opts) = @_;
71 1 return $schema->compile_runtime(%opts);
72 }
73  
74 2 ▶sub build_runtime {
Subroutine build_runtime: called CC=1 SCAR=0.0
Pod undocumented
75 2 my ($schema, %opts) = @_;
76 2 return $schema->build_runtime(%opts);
77 }
78  
79 177 ▶sub build_native_runtime {
Subroutine build_native_runtime: called CC=1 SCAR=0.0
Pod undocumented
80 177 my ($schema, %opts) = @_;
81 177 return $schema->build_native_runtime(%opts);
82 }
83  
84 4 ▶sub compile_native_bundle {
Subroutine compile_native_bundle: called CC=1 SCAR=0.0
Pod undocumented
85 4 my ($schema, $document, %opts) = @_;
86 4 return $schema->compile_native_bundle($document, %opts);
87 }
88  
89 1 ▶sub compile_native_program {
Subroutine compile_native_program: called CC=1 SCAR=0.0
Pod undocumented
90 1 my ($schema, $document, %opts) = @_;
91 1 return $schema->compile_native_program($document, %opts);
92 }
93  
94 2 ▶sub compile_native_bundle_descriptor {
Subroutine compile_native_bundle_descriptor: called CC=1 SCAR=0.0
Pod undocumented
95 2 my ($schema, $document, %opts) = @_;
96 2 return $schema->compile_native_bundle_descriptor($document, %opts);
97 }
98  
99 2 ▶sub execute_native {
Subroutine execute_native: called CC=1 SCAR=0.0
Pod undocumented
100 2 my ($schema, $document, %opts) = @_;
101 2 return $schema->execute_native($document, %opts);
102 }
103  
104 3 ▶sub execute_to_json {
Subroutine execute_to_json: called CC=2 SCAR=6.9
Pod undocumented
105 3 my ($schema, $document, $variables, %opts) = @_;
106 3 ▶ $opts{variables} = $variables if defined $variables;
Branch: 1 branch
BranchTrueFalseTotal
if defined $variables 1 2 3
107 3 my $runtime = $schema->build_native_runtime;
108 3 return $runtime->execute_document_to_json($document, %opts);
109 }
110  
111 52 ▶sub execute {
Subroutine execute: called CC=14 SCAR=29.0
Pod documented
112 52 my ($schema, $document, $variables_or_opts, @rest) = @_;
113 52 my %opts;
114 52 my %known_option = map { ($_ => 1) } qw(
115 variables
116 vars
117 root_value
118 context
119 operation_name
120 on_stall
121 promise_code
122 strict_sync
123 max_depth
124 max_nodes
125 max_cost
126 default_list_size
127 allow_introspection
128 );
129  
130 52 ▶ if (@rest) {
Branch: 3 branches
BranchTrueFalseTotal
if (@rest) { } 12 40 52
elsif (ref $variables_or_opts eq 'HASH') { } 7 33 40
elsif (defined $variables_or_opts) { } 0 33 33
131 12 my $third_is_hash = ref($variables_or_opts) eq 'HASH';
132 12 ▶ if ($third_is_hash && !grep { $known_option{$_} } keys %{$variables_or_opts}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($third_is_hash and not grep({$known_option{$_};} keys %{$variables_or_opts;})) { } 1 11 12
Condition66%2/3
$third_is_hash and not grep({$known_option{$_};} keys %{$variables_or_opts;})
!ll&&!rl&&r
1101
MC/DC50%1/2
$third_is_hash and not grep({$known_option{$_};} keys %{$variables_or_opts;})
$third_is_hash not grep({$known_option{$_};} keys %{$variables_or_opts;})
Truth table66%2/3
A and not(B)
A= $third_is_hashB= not grep({$known_option{$_};} keys %{$variables_or_opts;})
ABresult
0X0
100
111
133 # execute($schema, $query, \%variables, %opts): the positional hash
134 # is the variables payload, not part of the options.
135 1 %opts = @rest;
136 1 ▶ $opts{variables} = $variables_or_opts if !exists $opts{variables};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $opts{"variables"} 1 0 1
137 } else {
138 0 ▶ %opts = ($third_is_hash ? (%{$variables_or_opts}) : (), @rest);
Branch: 1 branch
BranchTrueFalseTotal
$third_is_hash ? : 0 11 11
139 }
140 } elsif (ref($variables_or_opts) eq 'HASH') {
141 7 ▶ if (grep { $known_option{$_} } keys %{$variables_or_opts}) {
Branch: 1 branch
BranchTrueFalseTotal
if (grep {$known_option{$_};} keys %{$variables_or_opts;}) { } 1 6 7
142 1 %opts = %{$variables_or_opts};
143 1 ▶ if (!exists $opts{variables}) {
Branch: 2 branches
BranchTrueFalseTotal
if (not exists $opts{'variables'}) { } 1 0 1
elsif (exists $opts{'vars'} and not exists $opts{'variables'}) { } 0 0 0
144 1 ▶ $opts{variables} = delete $opts{vars} if exists $opts{vars};
Branch: 1 branch
BranchTrueFalseTotal
if exists $opts{"vars"} 0 1 1
145 ▶ } elsif (exists $opts{vars} && !exists $opts{variables}) {
Condition0%0/3
exists $opts{"vars"} and not exists $opts{"variables"}
!ll&&!rl&&r
000
MC/DC0%0/2
exists $opts{"vars"} and not exists $opts{"variables"}
exists $opts{"vars"} not exists $opts{"variables"}
Truth table0%0/3
A and not(B)
A= exists $opts{"vars"}B= not exists $opts{"variables"}
ABresult
0X0
100
111
146 0 $opts{variables} = delete $opts{vars};
147 }
148 } else {
149 6 $opts{variables} = $variables_or_opts;
150 }
151 } elsif (defined $variables_or_opts) {
152 0 $opts{variables} = $variables_or_opts;
153 }
154  
155 die "promise_code is no longer supported; Promise::XS is built in and custom backends use async_adapter.\n"
156 52 ▶ if exists $opts{promise_code};
Branch: 1 branch
BranchTrueFalseTotal
if exists $opts{"promise_code"} 0 52 52
157  
158 52 my $runtime = $schema->build_native_runtime;
159 52 return $runtime->execute_document($document, %opts);
160 }
161  
162 93 1;
163 __END__
« blib/lib/GraphQL/Houtou/Async/Adapter.pm ↑ Summary blib/lib/GraphQL/Houtou/Type/List.pm »