« blib/lib/GraphQL/Houtou/Runtime/SchemaGraph.pm
↑ Summary
blib/lib/GraphQL/Houtou/Role/HashMappable.pm »
| 1 | package GraphQL::Houtou::Federation; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use 5.024; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 1 | ▶ | use Exporter 'import'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 1 | ▶ | use GraphQL::Houtou (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 1 | ▶ | use GraphQL::Houtou::Async::Adapter (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 1 | ▶ | use GraphQL::Houtou::Promise::PromiseXS qw(is_promise_xs_value); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 1 | ▶ | use GraphQL::Houtou::Schema (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 1 | our $VERSION = $GraphQL::Houtou::VERSION; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 1 | our @EXPORT_OK = qw(build_subgraph_schema); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 1 | my $FEDERATION_SDL = <<'SDL'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | scalar _Any | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | scalar federation__FieldSet | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | scalar federation__Scope | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | scalar federation__Policy | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | scalar federation__ContextFieldValue | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | scalar link__Import | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | enum link__Purpose { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | SECURITY | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | EXECUTION | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | directive @link( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | url: String! | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | as: String | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | for: link__Purpose | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | import: [link__Import] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | ) repeatable on SCHEMA | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | directive @key(fields: federation__FieldSet!, resolvable: Boolean = true) repeatable on OBJECT | INTERFACE | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | directive @external on FIELD_DEFINITION | OBJECT | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | directive @requires(fields: federation__FieldSet!) on FIELD_DEFINITION | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | directive @provides(fields: federation__FieldSet!) on FIELD_DEFINITION | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | directive @shareable repeatable on OBJECT | FIELD_DEFINITION | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | directive @inaccessible on FIELD_DEFINITION | OBJECT | INTERFACE | UNION | ARGUMENT_DEFINITION | SCALAR | ENUM | ENUM_VALUE | INPUT_OBJECT | INPUT_FIELD_DEFINITION | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | directive @tag(name: String!) repeatable on FIELD_DEFINITION | INTERFACE | OBJECT | UNION | ARGUMENT_DEFINITION | SCALAR | ENUM | ENUM_VALUE | INPUT_OBJECT | INPUT_FIELD_DEFINITION | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | directive @override(from: String!) on FIELD_DEFINITION | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | directive @composeDirective(name: String!) repeatable on SCHEMA | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | directive @interfaceObject on OBJECT | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | directive @authenticated on FIELD_DEFINITION | OBJECT | INTERFACE | SCALAR | ENUM | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | directive @requiresScopes(scopes: [[federation__Scope!]!]!) on FIELD_DEFINITION | OBJECT | INTERFACE | SCALAR | ENUM | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | directive @policy(policies: [[federation__Policy!]!]!) on FIELD_DEFINITION | OBJECT | INTERFACE | SCALAR | ENUM | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | directive @context(name: String!) repeatable on INTERFACE | OBJECT | UNION | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | directive @fromContext(field: federation__ContextFieldValue) on ARGUMENT_DEFINITION | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | type _Service { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | sdl: String! | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | SDL | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 8 | ▶ | sub build_subgraph_schema { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
build_subgraph_schema: called CC=20 SCAR=30.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 8 | my ($document, %opts) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 8 | ▶ | die "build_subgraph_schema requires an SDL document\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
not defined $document or ref $document or not $document =~ /\S/u
not defined $document or ref $document
MC/DC0%0/3
not defined $document or ref $document or not $document =~ /\S/u
not defined $document
ref $document
not $document =~ /\S/u
Truth table25%1/4
not(A) or B or not(C)
A= not defined $documentB= ref $documentC= not $document =~ /\S/u
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | if !defined($document) || ref($document) || $document !~ /\S/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 8 | ▶ | my $entity_resolvers = delete($opts{entity_resolvers}) || {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
delete $opts{'entity_resolvers'} || {}
MC/DC100%1/1
delete $opts{'entity_resolvers'} || {}
delete $opts{'entity_resolvers'}
Truth table100%2/2
A
A= delete $opts{'entity_resolvers'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 8 | my $has_async_adapter = exists $opts{async_adapter}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | my $async_adapter = GraphQL::Houtou::Async::Adapter->coerce( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | delete $opts{async_adapter}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 8 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 8 | my $builtin_async = $async_adapter->is_builtin; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | my $max_representations = exists($opts{max_representations}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 8 | ▶ | ? delete($opts{max_representations}) : 100; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 8 | ▶ | die "max_representations must be a positive integer\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $max_representations and $max_representations =~ /\A[1-9][0-9]*\z/u
MC/DC0%0/2
defined $max_representations and $max_representations =~ /\A[1-9][0-9]*\z/u
defined $max_representations
$max_representations =~ /\A[1-9][0-9]*\z/u
Truth table33%1/3
A and B
A= defined $max_representationsB= $max_representations =~ /\A[1-9][0-9]*\z/u
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | if !defined($max_representations) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | || $max_representations !~ /\A[1-9][0-9]*\z/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 8 | ▶ | die "entity_resolvers must be a hash reference\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | if ref($entity_resolvers) ne 'HASH'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 8 | my $ast = GraphQL::Houtou::parse($document); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 8 | my ($query_name, $entities) = _subgraph_shape($ast); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 8 | my @entity_names = sort keys %$entities; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 8 | my $entity_sdl = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 8 | ▶ | if (@entity_names) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 7 | $entity_sdl .= "union _Entity = " . join(' | ', @entity_names) . "\n\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 8 | $entity_sdl .= "extend type $query_name {\n _service: _Service!\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 8 | ▶ | $entity_sdl .= " _entities(representations: [_Any!]!): [_Entity]!\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | if @entity_names; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 8 | $entity_sdl .= "}\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 8 | ▶ | my $user_resolvers = delete($opts{resolvers}) || {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
delete $opts{'resolvers'} || {}
MC/DC100%1/1
delete $opts{'resolvers'} || {}
delete $opts{'resolvers'}
Truth table100%2/2
A
A= delete $opts{'resolvers'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 8 | ▶ | die "resolvers must be a hash reference\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | if ref($user_resolvers) ne 'HASH'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | my %resolvers = map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 8 | my $spec = $user_resolvers->{$_}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 2 | ▶ | ($_ => ref($spec) eq 'HASH' ? { %$spec } : $spec) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | } keys %$user_resolvers; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | _reserve_resolver( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | \%resolvers, '_Any', 'parse_value', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 9 | ▶ | sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 9 | my ($value) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 9 | ▶ | die "Federation representation must be an object\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | if ref($value) ne 'HASH'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 9 | return $value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 8 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 0 | ▶ | _reserve_resolver(\%resolvers, '_Any', 'serialize', sub { $_[0] }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | _reserve_resolver( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 2 | ▶ | \%resolvers, '_Service', 'sdl', sub { return $document }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 8 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | _reserve_resolver( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 2 | ▶ | \%resolvers, $query_name, '_service', sub { return {} }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 8 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 8 | ▶ | if (@entity_names) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 7 | for my $name (@entity_names) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | die "Missing entity resolver for '$name'\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 7 | ▶ | if ref($entity_resolvers->{$name}) ne 'CODE'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 6 | for my $name (sort keys %$entity_resolvers) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | die "Entity resolver provided for non-entity type '$name'\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 6 | ▶ | if !$entities->{$name}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | _reserve_resolver( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | \%resolvers, '_Entity', 'resolve_type', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 4 | ▶ | sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 4 | my ($value) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 4 | ▶ | return ref($value) eq 'HASH' ? $value->{__typename} : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 6 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | _reserve_resolver( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | \%resolvers, $query_name, '_entities', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 6 | ▶ | sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 6 | my (undef, $args, $context) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 6 | my $representations = $args->{representations}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 6 | ▶ | die "Federation representations must be an array\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | if ref($representations) ne 'ARRAY'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 6 | ▶ | die "Federation representations exceed max_representations ($max_representations)\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | if @$representations > $max_representations; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | return [ map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 5 | _resolve_representation( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | $_, $context, $entities, $entity_resolvers, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | $async_adapter, $builtin_async, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | } @$representations ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 6 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 7 | my $schema = GraphQL::Houtou::Schema->from_doc( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | "$FEDERATION_SDL\n$document\n$entity_sdl", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | %opts, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | resolvers => \%resolvers, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 7 | $entities = _validate_entity_keys($schema, $entities); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 5 | $schema->{_federation_subgraph_sdl} = $document; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 5 | $schema->{_federation_max_representations} = 0 + $max_representations; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 5 | ▶ | $schema->{_default_async_adapter} = $async_adapter if $has_async_adapter; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 5 | return $schema; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 44 | ▶ | sub _reserve_resolver { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_reserve_resolver: called CC=5 SCAR=16.7
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 44 | my ($resolvers, $type, $field, $callback) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 44 | my $spec = $resolvers->{$type}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 44 | ▶ | die "Resolvers for '$type' must be a hash reference\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $spec and ref $spec ne "HASH"
MC/DC0%0/2
defined $spec and ref $spec ne "HASH"
defined $spec
ref $spec ne "HASH"
Truth table66%2/3
A and B
A= defined $specB= ref $spec ne "HASH"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | if defined($spec) && ref($spec) ne 'HASH'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 44 | ▶ | $spec ||= ($resolvers->{$type} = {}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$spec ||= ($resolvers->{$type} = {})
MC/DC0%0/2
$spec ||= ($resolvers->{$type} = {})
$spec
($resolvers->{$type} = {})
Truth table66%2/3
A ||= B
A= $specB= ($resolvers->{$type} = {})
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | die "Resolver '$type.$field' is reserved by Federation\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 44 | ▶ | if exists $spec->{$field}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 44 | $spec->{$field} = $callback; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 44 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 8 | ▶ | sub _subgraph_shape { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_subgraph_shape: called CC=19 SCAR=33.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 8 | my ($ast) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 8 | my $query_name = 'Query'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 8 | my %types; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | my %entities; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 8 | for my $node (@$ast) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 21 | ▶ | my $kind = $node->{kind} || ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$node->{'kind'} || ''
MC/DC0%0/1
$node->{'kind'} || ''
$node->{'kind'}
Truth table50%1/2
A
A= $node->{'kind'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | $query_name = $node->{query} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 21 | ▶ | if $kind eq 'schema' && defined $node->{query}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$kind eq "schema" and defined $node->{"query"}
MC/DC0%0/2
$kind eq "schema" and defined $node->{"query"}
$kind eq "schema"
defined $node->{"query"}
Truth table66%2/3
A and B
A= $kind eq "schema"B= defined $node->{"query"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 21 | ▶ | next if $kind ne 'type' && $kind ne 'interface'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$kind ne "type" and $kind ne "interface"
MC/DC50%1/2
$kind ne "type" and $kind ne "interface"
$kind ne "type"
$kind ne "interface"
Truth table66%2/3
A and B
A= $kind ne "type"B= $kind ne "interface"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 16 | ▶ | $types{ $node->{name} } = 1 if !$node->{extension}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 16 | ▶ | next if $kind ne 'type'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 16 | ▶ | for my $directive (@{ $node->{directives} || [] }) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$node->{'directives'} || []
MC/DC100%1/1
$node->{'directives'} || []
$node->{'directives'}
Truth table100%2/2
A
A= $node->{'directives'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 7 | ▶ | next if ($directive->{name} || '') ne 'key'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$directive->{'name'} || ''
MC/DC0%0/1
$directive->{'name'} || ''
$directive->{'name'}
Truth table50%1/2
A
A= $directive->{'name'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 7 | my $resolvable = $directive->{arguments}{resolvable}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 7 | ▶ | next if defined($resolvable) && !$resolvable; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $resolvable and not $resolvable
MC/DC0%0/2
defined $resolvable and not $resolvable
defined $resolvable
not $resolvable
Truth table33%1/3
A and not(B)
A= defined $resolvableB= not $resolvable
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 7 | my $fields = $directive->{arguments}{fields}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 7 | ▶ | die "Federation \@key on '$node->{name}' requires a string fields argument\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
not defined $fields or ref $fields or $fields eq ""
not defined $fields or ref $fields
MC/DC0%0/3
not defined $fields or ref $fields or $fields eq ""
not defined $fields
ref $fields
$fields eq ""
Truth table25%1/4
not(A) or B or C
A= not defined $fieldsB= ref $fieldsC= $fields eq ""
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | if !defined($fields) || ref($fields) || $fields eq ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 7 | push @{ $entities{ $node->{name} } }, $fields; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | die "Federation query root type '$query_name' is not defined\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 8 | ▶ | if !$types{$query_name}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 8 | return ($query_name, \%entities); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 7 | ▶ | sub _validate_entity_keys { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_validate_entity_keys: called CC=8 SCAR=24.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 7 | my ($schema, $entities) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 7 | my $name2type = $schema->name2type; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 7 | my %compiled; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 7 | for my $entity_name (sort keys %$entities) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 6 | my $entity_type = $name2type->{$entity_name}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 6 | for my $fieldset (@{ $entities->{$entity_name} }) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 6 | my $document = eval { GraphQL::Houtou::parse("{ $fieldset }") }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 6 | my $error = $@; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 6 | ▶ | if ($error || ref($document) ne 'ARRAY' || @$document != 1) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
$error or ref $document ne "ARRAY" or @$document != 1
$error or ref $document ne "ARRAY"
MC/DC0%0/3
$error or ref $document ne "ARRAY" or @$document != 1
$error
ref $document ne "ARRAY"
@$document != 1
Truth table25%1/4
A or B or C
A= $errorB= ref $document ne "ARRAY"C= @$document != 1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 0 | ▶ | $error ||= 'invalid FieldSet'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$error ||= "invalid FieldSet"
MC/DC0%0/1
$error ||= "invalid FieldSet"
$error
Truth table0%0/2
A
A= $error
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 0 | $error =~ s/\s+\z//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 0 | die "Invalid \@key FieldSet on '$entity_name': $error\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | _validate_fieldset_selections( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 6 | ▶ | $entity_name, $entity_type, $document->[0]{selections} || [], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$document->[0]{'selections'} || []
MC/DC0%0/1
$document->[0]{'selections'} || []
$document->[0]{'selections'}
Truth table50%1/2
A
A= $document->[0]{'selections'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 4 | push @{ $compiled{$entity_name} }, $document->[0]{selections}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 5 | return \%compiled; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 6 | ▶ | sub _validate_fieldset_selections { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_validate_fieldset_selections: called CC=19 SCAR=35.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 6 | my ($coordinate, $type, $selections) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 6 | ▶ | die "Invalid \@key FieldSet on '$coordinate': fields must not be empty\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
ref $selections ne "ARRAY" or not @$selections
MC/DC0%0/2
ref $selections ne "ARRAY" or not @$selections
ref $selections ne "ARRAY"
not @$selections
Truth table33%1/3
A or not(B)
A= ref $selections ne "ARRAY"B= not @$selections
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | if ref($selections) ne 'ARRAY' || !@$selections; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 6 | ▶ | my $fields = $type->can('fields') ? $type->fields : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 6 | ▶ | die "Invalid \@key FieldSet on '$coordinate': type is not composite\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | if !$fields; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 6 | for my $selection (@$selections) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | die "Invalid \@key FieldSet on '$coordinate': only fields are allowed\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | if ($selection->{kind} || '') ne 'field' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | || $selection->{alias} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 6 | ▶ | || keys %{ $selection->{arguments} || {} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$selection->{'arguments'} || {}
MC/DC0%0/1
$selection->{'arguments'} || {}
$selection->{'arguments'}
Truth table50%1/2
A
A= $selection->{'arguments'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 6 | ▶ | || @{ $selection->{directives} || [] }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition38%5/13
($selection->{"kind"} || "") ne "field" or $selection->{"alias"} or keys %{$selection->{"arguments"} or {};} or @{$selection->{"directives"} or [];}
($selection->{"kind"} || "") ne "field" or $selection->{"alias"} or keys %{$selection->{"arguments"} or {};}
($selection->{"kind"} || "") ne "field" or $selection->{"alias"}
$selection->{'kind'} || ''
$selection->{'directives'} || []
MC/DC0%0/4
($selection->{"kind"} || "") ne "field" or $selection->{"alias"} or keys %{$selection->{"arguments"} or {};} or @{$selection->{"directives"} or [];}
$selection->{'kind'}
$selection->{"alias"}
keys %{$selection->{"arguments"} or {};}
@{$selection->{"directives"} or [];}
MC/DC0%0/1
$selection->{'directives'} || []
$selection->{'directives'}
Truth table0%0/5
A or B or C or D
A= $selection->{'kind'}B= $selection->{"alias"}C= keys %{$selection->{"arguments"} or {};}D= @{$selection->{"directives"} or [];}
Truth table50%1/2
A
A= $selection->{'directives'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 6 | my $name = $selection->{name}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 6 | ▶ | my $field = $fields->{$name} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | or die "Invalid \@key FieldSet: field '$coordinate.$name' does not exist\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 5 | my $field_type = $field->{type}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 5 | ▶ | $field_type = $field_type->of while ref($field_type) && $field_type->can('of'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
ref $field_type and $field_type->can("of")
MC/DC50%1/2
ref $field_type and $field_type->can("of")
ref $field_type
$field_type->can("of")
Truth table66%2/3
A and B
A= ref $field_typeB= $field_type->can("of")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 5 | ▶ | my $children = $selection->{selections} || []; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$selection->{'selections'} || []
MC/DC0%0/1
$selection->{'selections'} || []
$selection->{'selections'}
Truth table50%1/2
A
A= $selection->{'selections'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 5 | ▶ | if (@$children) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 0 | _validate_fieldset_selections("$coordinate.$name", $field_type, $children); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | elsif ($field_type->can('fields')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 1 | die "Invalid \@key FieldSet: composite field '$coordinate.$name' requires a selection\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | 4 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | 6 | ▶ | sub _resolve_representation { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_resolve_representation: called CC=11 SCAR=24.6
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 6 | my ($representation, $context, $entities, $entity_resolvers, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | $async_adapter, $builtin_async) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | 6 | ▶ | die "Federation representation must be an object\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | if ref($representation) ne 'HASH'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 6 | my $typename = $representation->{__typename}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 6 | ▶ | die "Federation representation requires a string __typename\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
not defined $typename or ref $typename or $typename eq ""
not defined $typename or ref $typename
MC/DC0%0/3
not defined $typename or ref $typename or $typename eq ""
not defined $typename
ref $typename
$typename eq ""
Truth table25%1/4
not(A) or B or C
A= not defined $typenameB= ref $typenameC= $typename eq ""
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | if !defined($typename) || ref($typename) || $typename eq ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | die "Unknown Federation entity type '$typename'\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 6 | ▶ | if !$entities->{$typename}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | die "Federation representation for '$typename' does not satisfy any \@key\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 5 | if !grep { _representation_has_fields($representation, $_) } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | 5 | ▶ | @{ $entities->{$typename} }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 4 | my $value = $entity_resolvers->{$typename}->($representation, $context); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 4 | ▶ | if ($builtin_async && is_promise_xs_value($value)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$builtin_async and is_promise_xs_value($value)
MC/DC100%2/2
$builtin_async and is_promise_xs_value($value)
$builtin_async
is_promise_xs_value($value)
Truth table100%3/3
A and B
A= $builtin_asyncB= is_promise_xs_value($value)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 1 | ▶ | return $value->then(sub { _tag_entity_result($typename, $_[0]) }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 3 | ▶ | if (!$builtin_async && $async_adapter->is_promise($value)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not $builtin_async and $async_adapter->is_promise($value)
MC/DC50%1/2
not $builtin_async and $async_adapter->is_promise($value)
not $builtin_async
$async_adapter->is_promise($value)
Truth table66%2/3
not(A) and B
A= not $builtin_asyncB= $async_adapter->is_promise($value)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | return $async_adapter->then( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 1 | ▶ | $value, sub { _tag_entity_result($typename, $_[0]) }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 1 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 2 | return _tag_entity_result($typename, $value); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | 5 | ▶ | sub _representation_has_fields { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_representation_has_fields: called CC=7 SCAR=20.7
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | 5 | my ($representation, $selections) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 5 | ▶ | return 0 if ref($representation) ne 'HASH'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | 5 | for my $selection (@$selections) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | 5 | my $name = $selection->{name}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 5 | ▶ | return 0 if !exists $representation->{$name}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 4 | ▶ | my $children = $selection->{selections} || []; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$selection->{'selections'} || []
MC/DC0%0/1
$selection->{'selections'} || []
$selection->{'selections'}
Truth table50%1/2
A
A= $selection->{'selections'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | return 0 if @$children | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 4 | ▶ | && !_representation_has_fields($representation->{$name}, $children); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
@$children and not _representation_has_fields($representation->{$name}, $children)
MC/DC0%0/2
@$children and not _representation_has_fields($representation->{$name}, $children)
@$children
not _representation_has_fields($representation->{$name}, $children)
Truth table33%1/3
A and not(B)
A= @$childrenB= not _representation_has_fields($representation->{$name}, $children)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | 4 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | 4 | ▶ | sub _tag_entity_result { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_tag_entity_result: called CC=3 SCAR=11.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | 4 | my ($typename, $value) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 4 | ▶ | return undef if !defined $value; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | 4 | ▶ | die "Federation entity resolver for '$typename' must return a hash reference or undef\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | if ref($value) ne 'HASH'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | 4 | return { %$value, __typename => $typename }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||