(<<'EOF');
type Query {
helloWorld: String
}
EOF
post '/graphql' => sub {
send_as JSON => execute(
$schema,
body_parameters->{query},
{ helloWorld => 'Hello world!' }
doc(<<'EOF');
type Query { dateTimeNow: DateTime }
EOF
post '/graphql' => sub {
send_as JSON => execute(
$schema,
body_parameters->{query},
{ dateTimeNow => sub { DateTime-
L::Type::Enum;
use GraphQL::Type::Scalar qw($String $Boolean);
use GraphQL::Debug qw(_debug);
use JSON::MaybeXS;
=head1 NAME
GraphQL::Introspection - Perl implementation of GraphQL
=cut
our $VERSI
A_FIELD_DEF
$TYPE_NAME_META_FIELD_DEF
);
use constant DEBUG => $ENV{GRAPHQL_DEBUG};
my $JSON_noutf8 = JSON::MaybeXS->new->utf8(0)->allow_nonref;
=head1 SYNOPSIS
use GraphQL::Introspection qw($Q
'a placeholder for a string or numeric value. However an Enum value is ' .
'returned in a JSON response as a string.',
fields => {
name => { type => $String->non_null },
description
nsions
Hash-ref of L<GraphQL::Type::Library/JSONable>s providing additional
information.
=cut
has extensions => (is => 'ro', isa => Optional[HashRef[JSONable]]);
=head1 METHODS
=head2 is
Is the
{
$self->message;
}
=head2 to_json
Converts to a JSON-able hash, in the format to send back as a member of
the C<errors> array in the results.
=cut
method to_json() :ReturnType(HashRef) {
+{ m
e 'Pegex::Receiver';
use Types::Standard -all;
use GraphQL::MaybeTypeCheck;
use JSON::MaybeXS;
use Carp;
my $JSON = JSON::MaybeXS->new->allow_nonref->canonical;
my @KINDHASH = qw(
scalar
union
_boolean (Any $param = undef) {
return unless defined $param;
return $param eq 'true' ? JSON->true : JSON->false;
}
method got_null (Any $param = undef) {
return unless defined $param;
return
Perl representation and the "GraphQL
representation". A "GraphQL representation" means something
JSON-encodeable: an "object" (in Perl terms, a hash), an array (Perl:
array-reference), string, number
n> be JSON-encoded, not things that I<have been> so encoded: this
means, among other things, do not surround strings in C<">, and for
boolean values, use the mechanism in L<JSON::MaybeXS>: C<JSON->tru
umentLocation JSONable
ErrorResult FieldsGot
);
use Type::Utils -all;
use Types::TypeTiny -all;
use Types::Standard -all;
use JSON::MaybeXS;
our $VERSION = '0.02';
my $JSON = JSON::MaybeXS->new
ype as
the C<type> (implemented with type L</ValuesMatchTypes>.
B<NB> this is a Perl value, not a JSON/GraphQL value.
=item description
Description.
=back
=cut
declare "FieldMapInput", as Map[
t[
line => Int,
column => Int,
];
=head2 JSONable
A value that will be JSON-able.
=cut
declare "JSONable",
as Any,
where { $JSON->encode($_); 1 };
=head2 ErrorResult
Hash-ref tha
Moo::Role;
use GraphQL::MaybeTypeCheck;
use Types::Standard -all;
use JSON::MaybeXS;
our $VERSION = '0.02';
my $JSON_noutf8 = JSON::MaybeXS->new->utf8(0)->allow_nonref;
=head1 NAME
GraphQL::Role::F
return $line if !$value->{is_deprecated};
$line .= ' @deprecated';
$line .= '(reason: ' . $JSON_noutf8->encode($value->{deprecation_reason}) . ')'
if $value->{deprecation_reason} ne
$
Types::Standard -all;
use JSON::MaybeXS;
with qw(GraphQL::Role::FieldDeprecation);
our $VERSION = '0.02';
use constant DEBUG => $ENV{GRAPHQL_DEBUG};
my $JSON_noutf8 = JSON::MaybeXS->new->utf8(0)->al
(', ', @argtuples).')' if @argtuples;
$line .= ': ' . $type->to_string;
$line .= ' = ' . $JSON_noutf8->encode(
$type->perl_to_graphql($field->{default_value})
) if exists $field->{de
my @directives = map {
my $args = $_->{arguments};
my @argtuples = map { "$_: " . $JSON_noutf8->encode($args->{$_}) } keys %$args;
'@' . $_->{name} . (@argtuples ? '(' . join(', '
doc(<<'EOF');
type Query { dateTimeNow: DateTime }
EOF
post '/graphql' => sub {
send_as JSON => execute(
$schema,
body_parameters->{query},
{ dateTimeNow => sub { DateTime-
GraphQL::Type::Library -all;
use GraphQL::Debug qw(_debug);
use Types::Standard -all;
use JSON::MaybeXS qw(JSON is_bool);
use Exporter 'import';
extends qw(GraphQL::Type);
with qw(
GraphQL::Role::In
ORT_OK = qw($Int $Float $String $Boolean $ID);
use constant DEBUG => $ENV{GRAPHQL_DEBUG};
my $JSON = JSON::MaybeXS->new->allow_nonref->canonical;
=head1 NAME
GraphQL::Type::Scalar - GraphQL scalar
_leave_undef(sub { !is_Bool($_[0]) and !is_bool($_[0]) and die "Not a Boolean.\n"; $_[0] ? JSON->true : JSON->false }),
parse_value => _leave_undef(sub { !is_Bool($_[0]) and !is_bool($_[0]) and die
ll;
use GraphQL::MaybeTypeCheck;
use GraphQL::Language::Parser qw(parse);
use GraphQL::Error;
use JSON::MaybeXS;
use GraphQL::Debug qw(_debug);
use GraphQL::Introspection qw(
$SCHEMA_META_FIELD_DEF
- Execute GraphQL queries
=cut
our @EXPORT_OK = qw(
execute
);
our $VERSION = '0.02';
my $JSON = JSON::MaybeXS->new->allow_nonref;
use constant DEBUG => $ENV{GRAPHQL_DEBUG}; # "DEBUG and" gets op
decoded JSON object supplied by a
client. E.g. for this query:
query q($input: TestInputObject) {
fieldWithObjectInput(input: $input)
}
The C<$variable_values> will need to be a JSON object