);
sub _build_ui_template {
my $self = shift;
$self->ui_template_class->new(json_encoder => $self->json_encoder, graphiql_version => $self->graphiql_version);
}
has graphiql => (
is =>
json_encoder => (
is => 'ro',
required => 1,
handles => {
json_encode => 'encode',
json_decode => 'decode',
},
builder => '_build_json_encoder',
);
our $DEFAULT_JSON_CLASS = 'JSON
::MaybeXS';
sub _build_json_encoder {
return our $JSON_ENCODER ||= Plack::Util::load_class($DEFAULT_JSON_CLASS)
->new
->utf8
->allow_nonref;
}
has exceptions_class => (
is
mplate {
$/ = undef;
return my $data = <DATA>;
}
has json_encoder => (
is => 'ro',
required => 1,
handles => {
json_encode => 'encode',
},
);
has graphiql_version => (
is =>
fe_serialize {
my ($self, $data) = @_;
if($data) {
my $json = $self->json_encode($data);
$json =~ s#/#\\/#g;
return $json;
} else {
return 'undefined';
}
}
sub process {
my
'post',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
body: JSON.stringify(graphQLParams),
credentials: 'include',