GraphQL...nt::http(3)
π GraphQL...nt::http(3)
okay so this page lives in the User Contributed Perl Documentation section of the manual, and it's literally about GraphQL::Client::http β GraphQL over HTTP, bestie. Let's get into it π«Ά
β¨ NAME β¨
GraphQL::Client::http β GraphQL over HTTP π
π VERSION π
version 0.605
π¦ SYNOPSIS π¦
my $transport = GraphQL::Client::http->new(
url => 'http://localhost:5000/graphql',
method => 'POST',
);
my $request = {
query => 'query Greet($name: String) { hello(name: $name) }',
operationName => 'Greet',
variables => { name => 'Bob' },
};
my $options = {
headers => {
authorization => 'Bearer s3cr3t',
},
};
my $response = $transport->execute($request, $options);
like, that's the whole vibe β¨
πΈ DESCRIPTION πΈ
so real talk: you probably shouldn't use this directly. Instead use GraphQL::Client. that's the main character, this is the supporting cast π
GraphQL::Client::http is a GraphQL transport for HTTP. GraphQL does not have to be transported via HTTP β nope, not required at all β but this is definitely the most common way. like, by a lot. no cap.
This also serves as a reference implementation for GraphQL::Client transports, iykyk π
π₯ ATTRIBUTES π₯
ua
A user agent, such as:
- instance of a
HTTP::Tiny(this is the default if no user agent is provided) π£ - instance of a
Mojo::UserAgent - the string
"AnyEvent::HTTP" - and more...
See "SUPPORTED USER AGENTS" in HTTP::AnyUA.
any_ua
The HTTP::AnyUA instance. Can be used to apply middleware if desired. like, go off, add your lil layers π§
url
The http URL of a GraphQL endpoint, e.g. "http://myapiserver/graphql".
method
The HTTP method to use when querying the GraphQL server. Can be one of:
"GET""POST"(default)
GraphQL servers should be able to handle both, but you can set this explicitly to one or the other if you're dealing with a server that is opinionated. you can also provide a different HTTP method, but anything other than "GET" and "POST" are less likely to work. so likeβ¦ proceed with caution bestie π
json
The JSON::XS (or compatible) object used for encoding and decoding data structures to and from the GraphQL server.
Defaults to a JSON::MaybeXS. cute, sensible, iconic π
π METHODS π
new
$transport = GraphQL::Client::http->new(%attributes);
Construct a new GraphQL HTTP transport. fresh out the box β¨
See "ATTRIBUTES".
execute
$response = $client->execute(\%request);
$response = $client->execute(\%request, \%options);
Get a response from the GraphQL server. the moment we've all been waiting for π
The %request structure must have a "query" key whose value is the query or mutation string. It may optionally have a "variables" hashref and an "operationName" string.
The %options structure is optional and may contain options passed through to the user agent. The only useful options are "headers" (which should have a hashref value) and "method" and "url" to override the attributes of the same names.
The response will either be a hashref with the following structure or a Future that resolves to such a hashref:
{
response => { # decoded response (may be undef if an error occurred)
data => {...},
errors => [...],
},
error => 'Something happened', # omitted if no error occurred
details => { # optional information which may aide troubleshooting
},
}
like, response can literally be undef if an error occurred, so don't come for me when you try to deref it π
β SEE ALSO β
<https://graphql.org/learn/serving-over-http/>
π BUGS π
Please report any bugs or feature requests on the bugtracker website <https://github.com/chazmcgarvey/graphql-client/issues>
When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature. basically: help me help you, bestie π«Ά
π AUTHOR π
Charles McGarvey <ccm@cpan.org>
π COPYRIGHT AND LICENSE π
This software is copyright (c) 2020 by Charles McGarvey.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
okay that's the whole page, mwah π this was rendered for perl v5.42.2 and dated 2026-02-15 β go forth and query, you absolute icon π
π¦ where this page comes from
- alpine 3.24: perl-graphql-client-doc 0.605-r1 Β· GPL-1.0-or-later OR Artistic-1.0-Perl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms