line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package GraphQL::Type::Interface; |
2
|
|
|
|
|
|
|
|
3
|
6
|
|
|
6
|
|
212353
|
use 5.014; |
|
6
|
|
|
|
|
51
|
|
4
|
6
|
|
|
6
|
|
36
|
use strict; |
|
6
|
|
|
|
|
14
|
|
|
6
|
|
|
|
|
202
|
|
5
|
6
|
|
|
6
|
|
34
|
use warnings; |
|
6
|
|
|
|
|
12
|
|
|
6
|
|
|
|
|
166
|
|
6
|
6
|
|
|
6
|
|
1100
|
use Moo; |
|
6
|
|
|
|
|
22498
|
|
|
6
|
|
|
|
|
39
|
|
7
|
6
|
|
|
6
|
|
5806
|
use Types::Standard -all; |
|
6
|
|
|
|
|
154373
|
|
|
6
|
|
|
|
|
73
|
|
8
|
6
|
|
|
6
|
|
294175
|
use GraphQL::MaybeTypeCheck; |
|
6
|
|
|
|
|
18
|
|
|
6
|
|
|
|
|
44
|
|
9
|
|
|
|
|
|
|
extends qw(GraphQL::Type); |
10
|
|
|
|
|
|
|
with qw( |
11
|
|
|
|
|
|
|
GraphQL::Role::Output |
12
|
|
|
|
|
|
|
GraphQL::Role::Composite |
13
|
|
|
|
|
|
|
GraphQL::Role::Abstract |
14
|
|
|
|
|
|
|
GraphQL::Role::Nullable |
15
|
|
|
|
|
|
|
GraphQL::Role::Named |
16
|
|
|
|
|
|
|
GraphQL::Role::FieldsOutput |
17
|
|
|
|
|
|
|
GraphQL::Role::FieldsEither |
18
|
|
|
|
|
|
|
); |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
our $VERSION = '0.02'; |
21
|
6
|
|
|
6
|
|
6313
|
use constant DEBUG => $ENV{GRAPHQL_DEBUG}; |
|
6
|
|
|
|
|
14
|
|
|
6
|
|
|
|
|
616
|
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=head1 NAME |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
GraphQL::Type::Interface - GraphQL interface type |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=head1 SYNOPSIS |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
use GraphQL::Type::Interface; |
30
|
|
|
|
|
|
|
my $ImplementingType; |
31
|
|
|
|
|
|
|
my $InterfaceType = GraphQL::Type::Interface->new( |
32
|
|
|
|
|
|
|
name => 'Interface', |
33
|
|
|
|
|
|
|
fields => { field_name => { type => $scalar_type } }, |
34
|
|
|
|
|
|
|
resolve_type => sub { |
35
|
|
|
|
|
|
|
return $ImplementingType; |
36
|
|
|
|
|
|
|
}, |
37
|
|
|
|
|
|
|
); |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
Has C<name>, C<description> from L<GraphQL::Role::Named>. |
42
|
|
|
|
|
|
|
Has C<fields> from L<GraphQL::Role::FieldsOutput>. |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=head2 resolve_type |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
Optional code-ref to resolve types. |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=cut |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
has resolve_type => (is => 'ro', isa => CodeRef); |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
method from_ast( |
53
|
|
|
|
|
|
|
HashRef $name2type, |
54
|
|
|
|
|
|
|
HashRef $ast_node, |
55
|
4
|
50
|
|
4
|
1
|
16
|
) :ReturnType(InstanceOf[__PACKAGE__]) { |
|
4
|
50
|
|
|
|
13
|
|
|
4
|
50
|
|
|
|
10
|
|
|
4
|
50
|
|
|
|
11
|
|
|
4
|
|
|
|
|
14
|
|
|
4
|
|
|
|
|
81
|
|
|
4
|
|
|
|
|
30
|
|
56
|
4
|
|
|
|
|
14
|
$self->new( |
57
|
|
|
|
|
|
|
$self->_from_ast_named($ast_node), |
58
|
|
|
|
|
|
|
$self->_from_ast_fields($name2type, $ast_node, 'fields'), |
59
|
|
|
|
|
|
|
); |
60
|
6
|
|
|
6
|
|
1824
|
} |
|
6
|
|
|
|
|
15
|
|
|
6
|
|
|
|
|
47
|
|
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
has to_doc => (is => 'lazy', isa => Str); |
63
|
|
|
|
|
|
|
sub _build_to_doc { |
64
|
4
|
|
|
4
|
|
303
|
my ($self) = @_; |
65
|
4
|
|
|
|
|
9
|
DEBUG and _debug('Interface.to_doc', $self); |
66
|
|
|
|
|
|
|
my @fieldlines = map { |
67
|
4
|
|
|
|
|
74
|
my ($main, @description) = @$_; |
|
4
|
|
|
|
|
17
|
|
68
|
|
|
|
|
|
|
( |
69
|
4
|
|
|
|
|
13
|
@description, |
70
|
|
|
|
|
|
|
$main, |
71
|
|
|
|
|
|
|
) |
72
|
|
|
|
|
|
|
} $self->_make_fieldtuples($self->fields); |
73
|
4
|
50
|
|
|
|
21
|
join '', map "$_\n", |
74
|
|
|
|
|
|
|
$self->_description_doc_lines($self->description), |
75
|
4
|
|
|
|
|
114
|
"interface @{[$self->name]} {", |
76
|
|
|
|
|
|
|
(map length() ? " $_" : "", @fieldlines), |
77
|
|
|
|
|
|
|
"}"; |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable(); |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
1; |