line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
use 5.014; |
3
|
5
|
|
|
5
|
|
4686
|
use strict; |
|
5
|
|
|
|
|
19
|
|
4
|
5
|
|
|
5
|
|
27
|
use warnings; |
|
5
|
|
|
|
|
11
|
|
|
5
|
|
|
|
|
109
|
|
5
|
5
|
|
|
5
|
|
26
|
use Moo; |
|
5
|
|
|
|
|
6
|
|
|
5
|
|
|
|
|
169
|
|
6
|
5
|
|
|
5
|
|
33
|
use Types::Standard -all; |
|
5
|
|
|
|
|
11
|
|
|
5
|
|
|
|
|
34
|
|
7
|
5
|
|
|
5
|
|
1801
|
use GraphQL::Type::Library -all; |
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
38
|
|
8
|
5
|
|
|
5
|
|
199428
|
use GraphQL::MaybeTypeCheck; |
|
5
|
|
|
|
|
14
|
|
|
5
|
|
|
|
|
48
|
|
9
|
5
|
|
|
5
|
|
59503
|
use GraphQL::Debug qw(_debug); |
|
5
|
|
|
|
|
13
|
|
|
5
|
|
|
|
|
38
|
|
10
|
5
|
|
|
5
|
|
28
|
extends qw(GraphQL::Type); |
|
5
|
|
|
|
|
17
|
|
|
5
|
|
|
|
|
450
|
|
11
|
|
|
|
|
|
|
with qw( |
12
|
|
|
|
|
|
|
GraphQL::Role::Input |
13
|
|
|
|
|
|
|
GraphQL::Role::Nullable |
14
|
|
|
|
|
|
|
GraphQL::Role::Named |
15
|
|
|
|
|
|
|
GraphQL::Role::FieldsInput |
16
|
|
|
|
|
|
|
GraphQL::Role::HashMappable |
17
|
|
|
|
|
|
|
GraphQL::Role::FieldsEither |
18
|
|
|
|
|
|
|
); |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
our $VERSION = '0.02'; |
21
|
|
|
|
|
|
|
use constant DEBUG => $ENV{GRAPHQL_DEBUG}; |
22
|
5
|
|
|
5
|
|
28
|
|
|
5
|
|
|
|
|
11
|
|
|
5
|
|
|
|
|
350
|
|
23
|
|
|
|
|
|
|
=head1 NAME |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
GraphQL::Type::InputObject - GraphQL input object type |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=head1 SYNOPSIS |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
use GraphQL::Type::InputObject; |
30
|
|
|
|
|
|
|
my $type = GraphQL::Type::InputObject->new( |
31
|
|
|
|
|
|
|
name => 'InputObject', |
32
|
|
|
|
|
|
|
fields => { field_name => { type => $scalar_type, resolve => sub { '' } }}, |
33
|
|
|
|
|
|
|
); |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
Has C<name>, C<description> from L<GraphQL::Role::Named>. |
38
|
|
|
|
|
|
|
Has C<fields> from L<GraphQL::Role::FieldsInput>. |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=head1 METHODS |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=head2 is_valid |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
True if given Perl hash-ref is a valid value for this type. |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=cut |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
method is_valid(Maybe[HashRef] $item) :ReturnType(Bool) { |
49
|
1
|
50
|
|
1
|
1
|
9895
|
return 1 if !defined $item; |
|
1
|
50
|
|
|
|
4
|
|
|
1
|
50
|
|
|
|
3
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
4
|
|
|
6
|
|
|
|
|
5574
|
|
50
|
6
|
50
|
|
|
|
24
|
my $fields = $self->fields; |
51
|
6
|
|
|
|
|
41
|
return if grep !$fields->{$_}{type}->is_valid( |
52
|
|
|
|
|
|
|
$item->{$_} // $fields->{$_}{default_value} |
53
|
|
|
|
|
|
|
), keys %$fields; |
54
|
19
|
50
|
66
|
|
|
453
|
1; |
55
|
19
|
|
|
|
|
51
|
} |
56
|
5
|
|
|
5
|
|
1790
|
|
|
5
|
|
|
|
|
16
|
|
|
5
|
|
|
|
|
43
|
|
57
|
|
|
|
|
|
|
=head2 uplift |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
Turn given Perl entity into valid value for this type if possible. Applies |
60
|
|
|
|
|
|
|
default values. |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=cut |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
method uplift(Maybe[HashRef] $item) :ReturnType(Maybe[HashRef]) { |
65
|
18
|
50
|
|
18
|
1
|
116
|
return $item if !defined $item; |
|
18
|
50
|
|
|
|
34
|
|
|
18
|
50
|
|
|
|
367
|
|
|
18
|
|
|
|
|
1467
|
|
|
62
|
|
|
|
|
113
|
|
|
62
|
|
|
|
|
280
|
|
66
|
5
|
100
|
|
|
|
4754
|
my $fields = $self->fields; |
67
|
5
|
|
|
|
|
13
|
$self->hashmap($item, $fields, sub { |
68
|
|
|
|
|
|
|
my ($key, $value) = @_; |
69
|
19
|
|
|
62
|
|
46
|
$fields->{$key}{type}->uplift( |
70
|
|
|
|
|
|
|
$value // $fields->{$key}{default_value} |
71
|
|
|
|
|
|
|
); |
72
|
19
|
|
|
|
|
44
|
}); |
73
|
5
|
|
|
|
|
27
|
} |
74
|
18
|
|
|
5
|
|
27
|
|
|
18
|
|
|
|
|
31
|
|
|
18
|
|
|
|
|
35
|
|
75
|
|
|
|
|
|
|
method graphql_to_perl(ExpectObject $item) :ReturnType(Maybe[HashRef]) { |
76
|
0
|
50
|
|
19
|
1
|
0
|
return $item if !defined $item; |
|
17
|
50
|
|
|
|
112
|
|
|
17
|
50
|
|
|
|
34
|
|
|
17
|
|
|
|
|
42
|
|
|
15
|
|
|
|
|
334
|
|
|
15
|
|
|
|
|
445
|
|
77
|
54
|
50
|
|
|
|
175
|
$item = $self->uplift($item); |
78
|
5
|
|
|
|
|
4868
|
my $fields = $self->fields; |
79
|
5
|
|
|
|
|
12
|
$self->hashmap($item, $fields, sub { |
80
|
|
|
|
|
|
|
$fields->{$_[0]}{type}->graphql_to_perl($_[1]); |
81
|
1
|
|
|
54
|
|
5
|
}); |
82
|
5
|
|
|
|
|
21
|
} |
83
|
19
|
|
|
5
|
|
27
|
|
|
19
|
|
|
|
|
37
|
|
|
19
|
|
|
|
|
36
|
|
84
|
|
|
|
|
|
|
method perl_to_graphql(ExpectObject $item) :ReturnType(Maybe[HashRef]) { |
85
|
1
|
50
|
|
1
|
1
|
4
|
return $item if !defined $item; |
|
1
|
50
|
|
|
|
10
|
|
|
1
|
50
|
|
|
|
4
|
|
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
36
|
|
|
1
|
|
|
|
|
33
|
|
86
|
1
|
50
|
|
|
|
11
|
$item = $self->uplift($item); |
87
|
5
|
|
|
|
|
4987
|
my $fields = $self->fields; |
88
|
5
|
|
|
|
|
14
|
$self->hashmap($item, $fields, sub { |
89
|
|
|
|
|
|
|
$fields->{$_[0]}{type}->perl_to_graphql($_[1]); |
90
|
5
|
|
|
1
|
|
26
|
}); |
91
|
5
|
|
|
|
|
18
|
} |
92
|
1
|
|
|
5
|
|
3
|
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
2
|
|
93
|
|
|
|
|
|
|
method from_ast( |
94
|
|
|
|
|
|
|
HashRef $name2type, |
95
|
|
|
|
|
|
|
HashRef $ast_node, |
96
|
|
|
|
|
|
|
) :ReturnType(InstanceOf[__PACKAGE__]) { |
97
|
5
|
50
|
|
5
|
1
|
22
|
$self->new( |
|
5
|
50
|
|
|
|
84
|
|
|
5
|
|
|
|
|
32
|
|
|
5
|
|
|
|
|
31
|
|
|
4
|
|
|
|
|
326
|
|
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
85
|
|
98
|
4
|
|
|
|
|
16
|
$self->_from_ast_named($ast_node), |
99
|
|
|
|
|
|
|
$self->_from_ast_fields($name2type, $ast_node, 'fields'), |
100
|
|
|
|
|
|
|
); |
101
|
|
|
|
|
|
|
} |
102
|
5
|
|
|
5
|
|
21
|
|
|
5
|
|
|
|
|
14
|
|
|
5
|
|
|
|
|
18
|
|
103
|
|
|
|
|
|
|
has to_doc => (is => 'lazy', isa => Str); |
104
|
|
|
|
|
|
|
my ($self) = @_; |
105
|
|
|
|
|
|
|
DEBUG and _debug('InputObject.to_doc', $self); |
106
|
4
|
|
|
4
|
|
12
|
my @fieldlines = map { |
107
|
4
|
|
|
|
|
22
|
my ($main, @description) = @$_; |
108
|
|
|
|
|
|
|
( |
109
|
4
|
|
|
|
|
131
|
@description, |
110
|
|
|
|
|
|
|
$main, |
111
|
|
|
|
|
|
|
) |
112
|
|
|
|
|
|
|
} $self->_make_fieldtuples($self->fields); |
113
|
|
|
|
|
|
|
join '', map "$_\n", |
114
|
|
|
|
|
|
|
$self->_description_doc_lines($self->description), |
115
|
|
|
|
|
|
|
"input @{[$self->name]} {", |
116
|
|
|
|
|
|
|
(map length() ? " $_" : "", @fieldlines), |
117
|
|
|
|
|
|
|
"}"; |
118
|
|
|
|
|
|
|
} |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable(); |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
1; |