line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package GraphQL::Type::Interface; |
2
|
|
|
|
|
|
|
|
3
|
6
|
|
|
6
|
|
200102
|
use 5.014; |
|
6
|
|
|
|
|
40
|
|
4
|
6
|
|
|
6
|
|
30
|
use strict; |
|
6
|
|
|
|
|
12
|
|
|
6
|
|
|
|
|
163
|
|
5
|
6
|
|
|
6
|
|
28
|
use warnings; |
|
6
|
|
|
|
|
10
|
|
|
6
|
|
|
|
|
150
|
|
6
|
6
|
|
|
6
|
|
1172
|
use Moo; |
|
6
|
|
|
|
|
21810
|
|
|
6
|
|
|
|
|
42
|
|
7
|
6
|
|
|
6
|
|
5384
|
use Types::Standard -all; |
|
6
|
|
|
|
|
145979
|
|
|
6
|
|
|
|
|
100
|
|
8
|
6
|
|
|
6
|
|
259252
|
use GraphQL::MaybeTypeCheck; |
|
6
|
|
|
|
|
17
|
|
|
6
|
|
|
|
|
47
|
|
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
|
|
5579
|
use constant DEBUG => $ENV{GRAPHQL_DEBUG}; |
|
6
|
|
|
|
|
15
|
|
|
6
|
|
|
|
|
587
|
|
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
|
24
|
) :ReturnType(InstanceOf[__PACKAGE__]) { |
|
4
|
50
|
|
|
|
18
|
|
|
4
|
50
|
|
|
|
9
|
|
|
4
|
50
|
|
|
|
14
|
|
|
4
|
|
|
|
|
16
|
|
|
4
|
|
|
|
|
93
|
|
|
4
|
|
|
|
|
32
|
|
56
|
4
|
|
|
|
|
21
|
$self->new( |
57
|
|
|
|
|
|
|
$self->_from_ast_named($ast_node), |
58
|
|
|
|
|
|
|
$self->_from_ast_fields($name2type, $ast_node, 'fields'), |
59
|
|
|
|
|
|
|
); |
60
|
6
|
|
|
6
|
|
1479
|
} |
|
6
|
|
|
|
|
12
|
|
|
6
|
|
|
|
|
43
|
|
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
has to_doc => (is => 'lazy', isa => Str); |
63
|
|
|
|
|
|
|
sub _build_to_doc { |
64
|
4
|
|
|
4
|
|
347
|
my ($self) = @_; |
65
|
4
|
|
|
|
|
8
|
DEBUG and _debug('Interface.to_doc', $self); |
66
|
|
|
|
|
|
|
my @fieldlines = map { |
67
|
4
|
|
|
|
|
103
|
my ($main, @description) = @$_; |
|
4
|
|
|
|
|
15
|
|
68
|
|
|
|
|
|
|
( |
69
|
4
|
|
|
|
|
16
|
@description, |
70
|
|
|
|
|
|
|
$main, |
71
|
|
|
|
|
|
|
) |
72
|
|
|
|
|
|
|
} $self->_make_fieldtuples($self->fields); |
73
|
4
|
50
|
|
|
|
23
|
join '', map "$_\n", |
74
|
|
|
|
|
|
|
$self->_description_doc_lines($self->description), |
75
|
4
|
|
|
|
|
128
|
"interface @{[$self->name]} {", |
76
|
|
|
|
|
|
|
(map length() ? " $_" : "", @fieldlines), |
77
|
|
|
|
|
|
|
"}"; |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable(); |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
1; |