| 1 | package GraphQL::Houtou::Type::Interface; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | 16 | ▶ | use 5.014; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | 16 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | 16 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||
| 7 | 16 | ▶ | use parent 'GraphQL::Houtou::Type'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | 16 | ▶ | use Role::Tiny::With; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | 16 | ▶ | use GraphQL::Houtou::Error (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | 16 | ▶ | use GraphQL::Houtou::Internal::TypeSupport qw( | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 11 | apply_fields_deprecation | ||||||||||||||||||||||||||||||||||||||||||
| 12 | description_doc_lines | ||||||||||||||||||||||||||||||||||||||||||
| 13 | from_ast_fields | ||||||||||||||||||||||||||||||||||||||||||
| 14 | from_ast_maptype | ||||||||||||||||||||||||||||||||||||||||||
| 15 | make_fieldtuples | ||||||||||||||||||||||||||||||||||||||||||
| 16 | named_from_ast | ||||||||||||||||||||||||||||||||||||||||||
| 17 | 16 | ); | |||||||||||||||||||||||||||||||||||||||||
| 18 | 16 | ▶ | use GraphQL::Houtou::Type::List (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 19 | 16 | ▶ | use GraphQL::Houtou::Type::NonNull (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||
| 21 | 16 | with qw( | |||||||||||||||||||||||||||||||||||||||||
| 22 | GraphQL::Houtou::Role::Output | ||||||||||||||||||||||||||||||||||||||||||
| 23 | GraphQL::Houtou::Role::Composite | ||||||||||||||||||||||||||||||||||||||||||
| 24 | GraphQL::Houtou::Role::Abstract | ||||||||||||||||||||||||||||||||||||||||||
| 25 | GraphQL::Houtou::Role::Named | ||||||||||||||||||||||||||||||||||||||||||
| 26 | GraphQL::Houtou::Role::FieldsOutput | ||||||||||||||||||||||||||||||||||||||||||
| 27 | GraphQL::Houtou::Role::FieldsEither | ||||||||||||||||||||||||||||||||||||||||||
| 28 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||
| 30 | 2 | ▶ | sub list { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
list: called CC=2 SCAR=9.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 31 | 2 | ▶ | $_[0]->{_houtou_list} ||= GraphQL::Houtou::Type::List->new(of => $_[0]); | ||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$_[0]{"_houtou_list"} ||= "GraphQL::Houtou::Type::List"->new("of", $_[0])
MC/DC0%0/2
$_[0]{"_houtou_list"} ||= "GraphQL::Houtou::Type::List"->new("of", $_[0])
$_[0]{"_houtou_list"}
"GraphQL::Houtou::Type::List"->new("of", $_[0])
Truth table33%1/3
A ||= B
A= $_[0]{"_houtou_list"}B= "GraphQL::Houtou::Type::List"->new("of", $_[0])
| |||||||||||||||||||||||||||||||||||||||||||
| 32 | } | ||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||
| 34 | 6 | ▶ | sub non_null { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
non_null: called CC=2 SCAR=9.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 35 | 6 | ▶ | $_[0]->{_houtou_non_null} ||= GraphQL::Houtou::Type::NonNull->new(of => $_[0]); | ||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$_[0]{"_houtou_non_null"} ||= "GraphQL::Houtou::Type::NonNull"->new("of", $_[0])
MC/DC0%0/2
$_[0]{"_houtou_non_null"} ||= "GraphQL::Houtou::Type::NonNull"->new("of", $_[0])
$_[0]{"_houtou_non_null"}
"GraphQL::Houtou::Type::NonNull"->new("of", $_[0])
Truth table33%1/3
A ||= B
A= $_[0]{"_houtou_non_null"}B= "GraphQL::Houtou::Type::NonNull"->new("of", $_[0])
| |||||||||||||||||||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||
| 38 | 16 | ▶ | use constant DEBUG => $ENV{GRAPHQL_DEBUG}; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||
| 40 | 40 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 41 | 40 | my ($class, %args) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 42 | 40 | ▶ | die "GraphQL::Houtou::Type::Interface requires name" if !defined $args{name}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 43 | 40 | ▶ | die "GraphQL::Houtou::Type::Interface requires fields" if !exists $args{fields}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 44 | 40 | my $self = $class->SUPER::new(%args); | |||||||||||||||||||||||||||||||||||||||||
| 45 | 40 | $self->{name} = $args{name}; | |||||||||||||||||||||||||||||||||||||||||
| 46 | 40 | $self->{description} = $args{description}; | |||||||||||||||||||||||||||||||||||||||||
| 47 | 40 | $self->{fields} = $args{fields}; | |||||||||||||||||||||||||||||||||||||||||
| 48 | 40 | ▶ | $self->{interfaces} = $args{interfaces} || []; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$args{'interfaces'} || []
MC/DC100%1/1
$args{'interfaces'} || []
$args{'interfaces'}
Truth table100%2/2
A
A= $args{'interfaces'}
| |||||||||||||||||||||||||||||||||||||||||||
| 49 | 40 | $self->{resolve_type} = $args{resolve_type}; | |||||||||||||||||||||||||||||||||||||||||
| 50 | 40 | $self->{tag_resolver} = $args{tag_resolver}; | |||||||||||||||||||||||||||||||||||||||||
| 51 | 40 | $self->{tag_map} = $args{tag_map}; | |||||||||||||||||||||||||||||||||||||||||
| 52 | 40 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||
| 55 | 2292 | ▶ | sub name { return $_[0]->{name} } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
name: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 56 | 210 | ▶ | sub description { return $_[0]->{description} } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
description: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 57 | 578 | ▶ | sub to_string { return $_[0]->{to_string} ||= $_[0]->name } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
to_string: called CC=2 SCAR=7.2
Pod
undocumented
Condition66%2/3
$_[0]{"to_string"} ||= $_[0]->name
MC/DC0%0/2
$_[0]{"to_string"} ||= $_[0]->name
$_[0]{"to_string"}
$_[0]->name
Truth table66%2/3
A ||= B
A= $_[0]{"to_string"}B= $_[0]->name
| |||||||||||||||||||||||||||||||||||||||||||
| 58 | 228 | ▶ | sub resolve_type { return $_[0]->{resolve_type} } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
resolve_type: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 59 | 23 | ▶ | sub tag_resolver { return $_[0]->{tag_resolver} } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
tag_resolver: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 60 | 23 | ▶ | sub tag_map { return $_[0]->{tag_map} } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
tag_map: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||
| 62 | 445 | ▶ | sub interfaces { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
interfaces: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 63 | 445 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 64 | 445 | ▶ | if (ref($self->{interfaces}) eq 'CODE') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 65 | 14 | $self->{interfaces} = $self->{interfaces}->(); | |||||||||||||||||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||||||||||||||||
| 67 | 445 | return $self->{interfaces}; | |||||||||||||||||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||
| 70 | 11 | ▶ | sub from_ast { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
from_ast: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 71 | 11 | my ($class, $name2type, $ast_node) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 72 | 11 | return $class->new( | |||||||||||||||||||||||||||||||||||||||||
| 73 | named_from_ast($ast_node), | ||||||||||||||||||||||||||||||||||||||||||
| 74 | from_ast_maptype($name2type, $ast_node, 'interfaces'), | ||||||||||||||||||||||||||||||||||||||||||
| 75 | from_ast_fields($name2type, $ast_node, 'fields'), | ||||||||||||||||||||||||||||||||||||||||||
| 76 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||||||
| 79 | 483 | ▶ | sub fields { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
fields: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 80 | 483 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 81 | 483 | ▶ | if (ref($self->{fields}) eq 'CODE') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 82 | 14 | $self->{fields} = $self->{fields}->(); | |||||||||||||||||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||||||||||||||||
| 84 | 483 | ▶ | if (!$self->{_fields_deprecation_applied}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 85 | 40 | $self->{fields} = apply_fields_deprecation($self->{fields}); | |||||||||||||||||||||||||||||||||||||||||
| 86 | 40 | $self->{_fields_deprecation_applied} = 1; | |||||||||||||||||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||||||||||||||||
| 88 | 483 | return $self->{fields}; | |||||||||||||||||||||||||||||||||||||||||
| 89 | } | ||||||||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||||||
| 91 | 7 | ▶ | sub to_doc { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
to_doc: called CC=4 SCAR=14.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 92 | 7 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 93 | 7 | ▶ | return $self->{to_doc} if exists $self->{to_doc}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 94 | my @fieldlines = map { | ||||||||||||||||||||||||||||||||||||||||||
| 95 | 5 | my ($main, @description) = @$_; | |||||||||||||||||||||||||||||||||||||||||
| 96 | 5 | (@description, $main); | |||||||||||||||||||||||||||||||||||||||||
| 97 | } make_fieldtuples($self->fields); | ||||||||||||||||||||||||||||||||||||||||||
| 98 | return $self->{to_doc} = join '', map "$_\n", | ||||||||||||||||||||||||||||||||||||||||||
| 99 | description_doc_lines($self->description), | ||||||||||||||||||||||||||||||||||||||||||
| 100 | 5 | ▶ | "interface @{[$self->name]}" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 101 | 0 | ▶ | . (@{ $self->interfaces } ? ' implements ' . join(' & ', map $_->name, @{ $self->interfaces }) : '') | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 102 | . " {", | ||||||||||||||||||||||||||||||||||||||||||
| 103 | (map length() ? " $_" : "", @fieldlines), | ||||||||||||||||||||||||||||||||||||||||||
| 104 | "}"; | ||||||||||||||||||||||||||||||||||||||||||
| 105 | } | ||||||||||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||||||||||
| 107 | 0 | ▶ | sub _ensure_valid_runtime_type { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_ensure_valid_runtime_type: not called CC=11 SCAR=48.8
| |||||||||||||||||||||||||||||||||||||||||||
| 108 | 0 | my ($self, $runtime_type_or_name, $context, $nodes, $info, $result) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 109 | 0 | my $schema = $context->{schema}; | |||||||||||||||||||||||||||||||||||||||||
| 110 | 0 | ▶ | my $runtime_cache = $context->{runtime_cache} || $schema->runtime_cache || $schema->prepare_runtime; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/6
$context->{'runtime_cache'} || $schema->runtime_cache || $schema->prepare_runtime
$context->{"runtime_cache"} or $schema->runtime_cache
MC/DC0%0/3
$context->{'runtime_cache'} || $schema->runtime_cache || $schema->prepare_runtime
$context->{"runtime_cache"}
$schema->runtime_cache
$schema->prepare_runtime
Truth table0%0/4
A or B || C
A= $context->{"runtime_cache"}B= $schema->runtime_cacheC= $schema->prepare_runtime
| |||||||||||||||||||||||||||||||||||||||||||
| 111 | 0 | ▶ | my $name2type = $runtime_cache->{name2type} || $schema->name2type; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$runtime_cache->{'name2type'} || $schema->name2type
MC/DC0%0/2
$runtime_cache->{'name2type'} || $schema->name2type
$runtime_cache->{'name2type'}
$schema->name2type
Truth table0%0/3
A || B
A= $runtime_cache->{'name2type'}B= $schema->name2type
| |||||||||||||||||||||||||||||||||||||||||||
| 112 | 0 | ▶ | my $possible_type_map = $runtime_cache->{possible_type_map} ||= {}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$runtime_cache->{"possible_type_map"} ||= {}
MC/DC0%0/1
$runtime_cache->{"possible_type_map"} ||= {}
$runtime_cache->{"possible_type_map"}
Truth table0%0/2
A
A= $runtime_cache->{"possible_type_map"}
| |||||||||||||||||||||||||||||||||||||||||||
| 113 | my $runtime_type = ref($runtime_type_or_name) | ||||||||||||||||||||||||||||||||||||||||||
| 114 | ? $runtime_type_or_name | ||||||||||||||||||||||||||||||||||||||||||
| 115 | 0 | ▶ | : $name2type->{$runtime_type_or_name}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||||||||||||||||
| 117 | 0 | ▶ | die GraphQL::Houtou::Error->new( | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$runtime_type and $runtime_type->isa("GraphQL::Type::Object") || $runtime_type->isa("GraphQL::Houtou::Type::Object")
$runtime_type->isa("GraphQL::Type::Object") or $runtime_type->isa("GraphQL::Houtou::Type::Object")
MC/DC0%0/3
$runtime_type and $runtime_type->isa("GraphQL::Type::Object") || $runtime_type->isa("GraphQL::Houtou::Type::Object")
$runtime_type
$runtime_type->isa("GraphQL::Type::Object")
$runtime_type->isa("GraphQL::Houtou::Type::Object")
Truth table0%0/4
A and B or C
A= $runtime_typeB= $runtime_type->isa("GraphQL::Type::Object")C= $runtime_type->isa("GraphQL::Houtou::Type::Object")
| |||||||||||||||||||||||||||||||||||||||||||
| 118 | 0 | message => "Abstract type @{[$self->name]} must resolve to an " . | |||||||||||||||||||||||||||||||||||||||||
| 119 | 0 | "Object type at runtime for field @{[$info->{parent_type}->name]}." . | |||||||||||||||||||||||||||||||||||||||||
| 120 | 0 | "@{[$info->{field_name}]} with value $result, received '@{[$runtime_type->name]}'.", | |||||||||||||||||||||||||||||||||||||||||
| 121 | nodes => [ $nodes ], | ||||||||||||||||||||||||||||||||||||||||||
| 122 | ) if !$runtime_type | ||||||||||||||||||||||||||||||||||||||||||
| 123 | || !($runtime_type->isa('GraphQL::Type::Object') || $runtime_type->isa('GraphQL::Houtou::Type::Object')); | ||||||||||||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||||||||||||
| 125 | die GraphQL::Houtou::Error->new( | ||||||||||||||||||||||||||||||||||||||||||
| 126 | 0 | message => "Runtime Object type '@{[$runtime_type->name]}' is not a possible type for " . | |||||||||||||||||||||||||||||||||||||||||
| 127 | 0 | "'@{[$self->name]}'.", | |||||||||||||||||||||||||||||||||||||||||
| 128 | nodes => [ $nodes ], | ||||||||||||||||||||||||||||||||||||||||||
| 129 | ) if !( | ||||||||||||||||||||||||||||||||||||||||||
| 130 | (exists $possible_type_map->{ $self->name } | ||||||||||||||||||||||||||||||||||||||||||
| 131 | 0 | ▶ | ? $possible_type_map->{ $self->name }{ $runtime_type->name } | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 132 | : $schema->is_possible_type($self, $runtime_type)) | ||||||||||||||||||||||||||||||||||||||||||
| 133 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||||||||||||
| 135 | 0 | return $runtime_type; | |||||||||||||||||||||||||||||||||||||||||
| 136 | } | ||||||||||||||||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||||||||||||||||
| 138 | 16 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||||||||||||
| 140 | __END__ | ||||||||||||||||||||||||||||||||||||||||||