line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
use 5.014; |
3
|
18
|
|
|
18
|
|
9357
|
use strict; |
|
18
|
|
|
|
|
62
|
|
4
|
18
|
|
|
18
|
|
92
|
use warnings; |
|
18
|
|
|
|
|
36
|
|
|
18
|
|
|
|
|
424
|
|
5
|
18
|
|
|
18
|
|
133
|
use Moo::Role; |
|
18
|
|
|
|
|
55
|
|
|
18
|
|
|
|
|
555
|
|
6
|
18
|
|
|
18
|
|
93
|
use GraphQL::MaybeTypeCheck; |
|
18
|
|
|
|
|
35
|
|
|
18
|
|
|
|
|
148
|
|
7
|
18
|
|
|
18
|
|
6738
|
use Types::Standard -all; |
|
18
|
|
|
|
|
40
|
|
|
18
|
|
|
|
|
139
|
|
8
|
18
|
|
|
18
|
|
91
|
use JSON::MaybeXS; |
|
18
|
|
|
|
|
35
|
|
|
18
|
|
|
|
|
150
|
|
9
|
18
|
|
|
18
|
|
718185
|
|
|
18
|
|
|
|
|
48
|
|
|
18
|
|
|
|
|
4734
|
|
10
|
|
|
|
|
|
|
our $VERSION = '0.02'; |
11
|
|
|
|
|
|
|
my $JSON_noutf8 = JSON::MaybeXS->new->utf8(0)->allow_nonref; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 NAME |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
GraphQL::Role::FieldDeprecation - object role implementing deprecation of fields |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head1 SYNOPSIS |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
with qw(GraphQL::Role::FieldDeprecation); |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
# or runtime |
22
|
|
|
|
|
|
|
Role::Tiny->apply_roles_to_object($foo, qw(GraphQL::Role::FieldDeprecation)); |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=head1 DESCRIPTION |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
Implements deprecation of fields. |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=cut |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
has _fields_deprecation_applied => (is => 'rw'); |
31
|
|
|
|
|
|
|
my ($self, $key) = @_; |
32
|
|
|
|
|
|
|
return if $self->_fields_deprecation_applied; |
33
|
2835
|
|
|
2835
|
|
5630
|
$self->_fields_deprecation_applied(1); |
34
|
2835
|
100
|
|
|
|
8370
|
my $v = $self->{$key} = { %{$self->{$key}} }; # copy on write |
35
|
321
|
|
|
|
|
723
|
for my $name (keys %$v) { |
36
|
321
|
|
|
|
|
495
|
if (defined $v->{$name}{deprecation_reason}) { |
|
321
|
|
|
|
|
1532
|
|
37
|
321
|
|
|
|
|
1250
|
$v->{$name} = { %{$v->{$name}}, is_deprecated => 1 }; # copy on write |
38
|
1181
|
100
|
|
|
|
2454
|
} |
39
|
12
|
|
|
|
|
18
|
} |
|
12
|
|
|
|
|
49
|
|
40
|
|
|
|
|
|
|
}; |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
method _from_ast_field_deprecate( |
43
|
|
|
|
|
|
|
Str $key, |
44
|
|
|
|
|
|
|
HashRef $values, |
45
|
|
|
|
|
|
|
) { |
46
|
|
|
|
|
|
|
my $value = +{ %{$values->{$key}} }; |
47
|
128
|
50
|
|
128
|
|
286
|
my $directives = delete $value->{directives}; # ok as copy |
|
128
|
50
|
|
|
|
267
|
|
|
128
|
50
|
|
|
|
203
|
|
|
128
|
50
|
|
|
|
211
|
|
|
128
|
|
|
|
|
270
|
|
|
128
|
|
|
|
|
1102
|
|
|
128
|
|
|
|
|
710
|
|
48
|
128
|
|
|
|
|
174
|
return $values unless $directives and @$directives; |
|
128
|
|
|
|
|
472
|
|
49
|
128
|
|
|
|
|
242
|
my ($deprecated) = grep $_->{name} eq 'deprecated', @$directives; |
50
|
128
|
100
|
66
|
|
|
563
|
return $values unless $deprecated; |
51
|
9
|
|
|
|
|
42
|
my $reason = $deprecated->{arguments}{reason} |
52
|
9
|
100
|
|
|
|
30
|
// $GraphQL::Directive::DEPRECATED->args->{reason}{default_value}; |
53
|
|
|
|
|
|
|
+{ |
54
|
4
|
|
66
|
|
|
71
|
%$values, |
55
|
|
|
|
|
|
|
$key => { %$value, deprecation_reason => $reason }, |
56
|
4
|
|
|
|
|
577
|
}; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
method _to_doc_field_deprecate( |
60
|
|
|
|
|
|
|
Str $line, |
61
|
|
|
|
|
|
|
HashRef $value, |
62
|
|
|
|
|
|
|
) { |
63
|
|
|
|
|
|
|
return $line if !$value->{is_deprecated}; |
64
|
99
|
50
|
|
99
|
|
193
|
$line .= ' @deprecated'; |
|
99
|
50
|
|
|
|
183
|
|
|
99
|
50
|
|
|
|
127
|
|
|
99
|
50
|
|
|
|
160
|
|
|
99
|
|
|
|
|
227
|
|
|
99
|
|
|
|
|
1007
|
|
|
99
|
|
|
|
|
621
|
|
65
|
99
|
100
|
|
|
|
480
|
$line .= '(reason: ' . $JSON_noutf8->encode($value->{deprecation_reason}) . ')' |
66
|
4
|
|
|
|
|
11
|
if $value->{deprecation_reason} ne |
67
|
|
|
|
|
|
|
$GraphQL::Directive::DEPRECATED->args->{reason}{default_value}; |
68
|
|
|
|
|
|
|
$line; |
69
|
4
|
100
|
|
|
|
73
|
} |
70
|
4
|
|
|
|
|
156
|
|
71
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable(); |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
1; |