X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=lib%2FGraphQL%2FClient%2Fhttp.pm;h=795f2e7ee9e97c72ffc5065e5f09ae2d8c5b9dcf;hb=46eab3f23427ab1151a7b4187b365bf1e211ec12;hp=9c89444a632771c56a09c489d0669979c8ff9caa;hpb=6ceb671d38a8564d8bbe6e52a33e54ebdc4ca282;p=chaz%2Fgraphql-client diff --git a/lib/GraphQL/Client/http.pm b/lib/GraphQL/Client/http.pm index 9c89444..795f2e7 100644 --- a/lib/GraphQL/Client/http.pm +++ b/lib/GraphQL/Client/http.pm @@ -42,7 +42,7 @@ sub execute { my $encoded_data = $self->json->encode($data); $options->{content} = $encoded_data; $options->{headers}{'content-length'} = length $encoded_data; - $options->{headers}{'content-type'} = 'application/json'; + $options->{headers}{'content-type'} = 'application/json;charset=UTF-8'; } return $self->_handle_response($self->any_ua->request($method, $url, $options)); @@ -90,6 +90,8 @@ sub _handle_error { my $reason = $resp->{reason} // ''; my $message = "HTTP transport returned $resp->{status} ($reason): $content"; + chomp $message; + return { error => $message, response => $data, @@ -175,7 +177,7 @@ __END__ authorization => 'Bearer s3cr3t', }, }; - my $response = $client->execute($request, $options); + my $response = $transport->execute($request, $options); =head1 DESCRIPTION @@ -201,8 +203,8 @@ See L. Get a response from the GraphQL server. -The C<%data> structure must have a C key whose value is the query or mutation string. It may -optionally have a C hashref and an C string. +The C<%request> structure must have a C key whose value is the query or mutation string. It +may optionally have a C hashref and an C string. The C<%options> structure is optional and may contain options passed through to the user agent. The only useful options are C (which should have a hashref value) and C and C to @@ -216,7 +218,7 @@ such a hashref: data => {...}, errors => [...], }, - error => 'Something happened', # may be ommitted if no error occurred + error => 'Something happened', # omitted if no error occurred details => { # optional information which may aide troubleshooting }, }