GraphQL...nt::http(3)

πŸ“¦ version 0.605, in alpine 3.24

πŸ’… 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>

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