line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
use strict; |
3
|
3
|
|
|
3
|
|
93200
|
use warnings; |
|
3
|
|
|
|
|
15
|
|
|
3
|
|
|
|
|
78
|
|
4
|
3
|
|
|
3
|
|
15
|
use GraphQL::Type::Scalar; |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
62
|
|
5
|
3
|
|
|
3
|
|
697
|
use GraphQL::Plugin::Type; |
|
3
|
|
|
|
|
12
|
|
|
3
|
|
|
|
|
153
|
|
6
|
3
|
|
|
3
|
|
19
|
use DateTime::Format::ISO8601; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
16
|
|
7
|
3
|
|
|
3
|
|
1824
|
|
|
3
|
|
|
|
|
2492412
|
|
|
3
|
|
|
|
|
433
|
|
8
|
|
|
|
|
|
|
=head1 NAME |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
GraphQL::Plugin::Type::DateTime - GraphQL DateTime scalar type |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 SYNOPSIS |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
use GraphQL::Schema; |
15
|
|
|
|
|
|
|
use GraphQL::Plugin::Type::DateTime; |
16
|
|
|
|
|
|
|
use GraphQL::Execution qw(execute); |
17
|
|
|
|
|
|
|
my $schema = GraphQL::Schema->from_doc(<<'EOF'); |
18
|
|
|
|
|
|
|
type Query { dateTimeNow: DateTime } |
19
|
|
|
|
|
|
|
EOF |
20
|
|
|
|
|
|
|
post '/graphql' => sub { |
21
|
|
|
|
|
|
|
send_as JSON => execute( |
22
|
|
|
|
|
|
|
$schema, |
23
|
|
|
|
|
|
|
body_parameters->{query}, |
24
|
|
|
|
|
|
|
{ dateTimeNow => sub { DateTime->now } }, |
25
|
|
|
|
|
|
|
undef, |
26
|
|
|
|
|
|
|
body_parameters->{variables}, |
27
|
|
|
|
|
|
|
body_parameters->{operationName}, |
28
|
|
|
|
|
|
|
undef, |
29
|
|
|
|
|
|
|
); |
30
|
|
|
|
|
|
|
}; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=head1 DESCRIPTION |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
Implements a non-standard GraphQL scalar type that represents |
35
|
|
|
|
|
|
|
a point in time, canonically represented in ISO 8601 format, |
36
|
|
|
|
|
|
|
e.g. C<20171114T07:41:10>. |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=cut |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
my $iso8601 = DateTime::Format::ISO8601->new; |
41
|
|
|
|
|
|
|
GraphQL::Plugin::Type->register( |
42
|
|
|
|
|
|
|
GraphQL::Type::Scalar->new( |
43
|
|
|
|
|
|
|
name => 'DateTime', |
44
|
|
|
|
|
|
|
description => |
45
|
|
|
|
|
|
|
'The `DateTime` scalar type represents a point in time. ' . |
46
|
|
|
|
|
|
|
'Canonically represented using ISO 8601 format, e.g. 20171114T07:41:10, '. |
47
|
|
|
|
|
|
|
'which is 14 November 2017 at 07:41am.', |
48
|
|
|
|
|
|
|
serialize => sub { return if !defined $_[0]; $_[0].'' }, |
49
|
|
|
|
|
|
|
parse_value => sub { return if !defined $_[0]; $iso8601->parse_datetime(@_); }, |
50
|
|
|
|
|
|
|
) |
51
|
|
|
|
|
|
|
); |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
1; |