GRAPHQL(1)
π GRAPHQL(1) β the command-line GraphQL client, bestie
okay so this is the manual page for graphql (that's GRAPHQL(1) if you're being formal β¨), and honestly? it's giving "tiny tool, huge slay." let's get into it π«Ά
πΈ NAME
graphql β Command-line GraphQL client. that's it. that's the name. iconic.
π VERSION
version 0.605 β yes bestie, write it down, we're being precise π
β SYNOPSIS
graphql <URL> <QUERY> [ [--variables JSON] | [--variable KEY=VALUE]... ]
[--operation-name NAME] [--transport KEY=VALUE]...
[--[no-]unpack] [--filter JSONPATH]
[--format json|json:pretty|yaml|perl|csv|tsv|table] [--output FILE]
graphql --version|--help|--manual
π¦ DESCRIPTION
graphql is a command-line program for executing queries and mutations on a GraphQL server β the server being over at <https://graphql.org/> if you wanna go say hi π
literally all it does is send your query and hand you back the response. and it does it well. periodt.
π INSTALL
There are several ways to install graphql to your system. pick your fighter π
π from CPAN
You can install graphql using cpanm:
cpanm GraphQL::Client
π§ from GitHub
You can also choose to download graphql as a self-contained executable:
curl -OL https://raw.githubusercontent.com/chazmcgarvey/graphql-client/solo/graphql
chmod +x graphql
To hack on the code, clone the repo instead:
git clone https://github.com/chazmcgarvey/graphql-client.git
cd graphql-client
make bootstrap # installs dependencies; requires cpanm
yes, that comment in the middle is load-bearing β make bootstrap installs dependencies and it requires cpanm, no cap π
β¨ OPTIONS
okay this is the part where i hold your hand through every single flag. no skipping, we don't do that here π
π --url URL
The URL of the GraphQL server endpoint.
If no --url option is given, the first argument is assumed to be the URL.
This option is required. like, actually required. you can't skip it, bestie π
Alias: -u
π --query STR
The query or mutation to execute.
If no --query option is given, the next argument (after URL) is assumed to be the query.
If the value is - (which is the default), the query will be read from STDIN.
See: <https://graphql.org/learn/queries/>
Alias: --mutation
π --variables JSON
Provide the variables as a JSON object. one blob, all at once, very "send the whole group chat message" energy π₯
Aliases: --vars, -V
π --variable KEY=VALUE
An alternative way to provide variables one at a time. This option can be repeated to provide multiple variables.
If used in combination with --variables JSON, this option is silently ignored. (yes, silently β it will not warn you, it will just vibe past you π)
See: <https://graphql.org/learn/queries/#variables>
Aliases: --var, -d
π --operation-name NAME
Inform the server which query/mutation to execute.
Alias: -n
π --output FILE
Write the response to a file instead of STDOUT.
Alias: -o
π --transport KEY=VALUE
Key-value pairs for configuring the transport (usually HTTP).
Alias: -t
π --format STR
Specify the output format to use. See "FORMAT". π
Alias: -f
π --unpack
Enables unpack mode.
By default, the response structure is printed as-is from the server, and the program exits 0.
When unpack mode is enabled, if the response completes with no errors, only the data section of the response is printed and the program exits 0. If the response has errors, the whole response structure is printed as-is and the program exits 1. See "EXAMPLES" to see what this looks like in practice.
Use --no-unpack to disable if unpack mode was enabled via GRAPHQL_CLIENT_OPTIONS.
π --filter JSONPATH
Filter the response based on a JSONPath expression.
Requires JSON::Path. (so like, install it first, don't come crying to me π)
Alias: -p
π FORMAT
The argument for --format STR can be one of:
csvβ Comma-separated values (requiresText::CSV)json:prettyβ Human-readable JSON (default)jsonβ JSONperlβ Perl code (requiresData::Dumper)tableβ Table (requiresText::Table::Any)tsvβ Tab-separated values (requiresText::CSV)yamlβ YAML (requiresYAML)
The csv, tsv, and table formats will only work if the response has a particular shape:
{
"data" : {
"onefield" : [
{
"key" : "value",
...
},
...
]
}
}
or
{
"data" : {
"onefield" : [
"value",
...
]
}
}
If the response cannot be formatted, the default format will be used instead, an error message will be printed to STDERR, and the program will exit 3. so bestie, that's a soft fail β you get JSON and an exit code that says "this wasn't what you asked for" π
Table formatting can be done by one of several different modules, each with its own features and bugs. (yes, bugs, plural, they said it not me π) The default module is Text::Table::Tiny, but this can be overridden using the PERL_TEXT_TABLE environment variable if desired, like this:
PERL_TEXT_TABLE=Text::Table::HTML graphql ... -f table
The list of supported modules is at @BACKENDS in Text::Table::Any.
π₯ EXAMPLES
Different ways to provide the query/mutation to execute:
graphql http://myserver/graphql {hello}
echo {hello} | graphql http://myserver/graphql
graphql http://myserver/graphql <<END
> {hello}
> END
graphql http://myserver/graphql
Interactive mode engaged! Waiting for a query on <STDIN>...
{hello}
^D
Execute a query with variables:
graphql http://myserver/graphql <<END --var episode=JEDI
> query HeroNameAndFriends($episode: Episode) {
> hero(episode: $episode) {
> name
> friends {
> name
> }
> }
> }
> END
graphql http://myserver/graphql --vars '{"episode":"JEDI"}'
Configure the transport:
graphql http://myserver/graphql {hello} -t headers.authorization='Basic s3cr3t'
This example shows the effect of --unpack:
graphql http://myserver/graphql {hello}
# Output:
{
"data" : {
"hello" : "Hello world!"
}
}
graphql http://myserver/graphql {hello} --unpack
# Output:
{
"hello" : "Hello world!"
}
see how the whole "data" wrapper just evaporates? that's the unpack slay β¨
π¦ ENVIRONMENT
Some environment variables affect the way graphql behaves:
GRAPHQL_CLIENT_DEBUGβ Set to1to print diagnostic messages to STDERR.GRAPHQL_CLIENT_HTTP_USER_AGENTβ Set the HTTP user agent string.GRAPHQL_CLIENT_OPTIONSβ Set the default set of options.PERL_TEXT_TABLEβ Set table format backend; see "FORMAT".
π EXIT STATUS
Here is a consolidated summary of what exit statuses mean:
0β Success π1β Client or server errors2β Option usage is wrong3β Could not format the response as requested
memorize these, they're your emotional support numbers π
π SEE ALSO
- GraphQL::Client β Programmatic interface
π 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. fr fr, a failing test is worth a thousand words π«Ά
πΈ AUTHOR
Charles McGarvey <ccm@cpan.org>
π¦ CONTRIBUTOR
jwright <jwright@ecstuning.com>
π 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.
and that's the whole page, bestie π this little number is perl v5.42.2, dated 2026-02-15, and it's the GRAPHQL(1) manpage β 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