Skip to the content
Documentation
Help Start
Reading in:
  • German: 9,059 of 9,059 pages
About the help in other languages
All help pages

exp:expgraphqlquery

Run a GraphQL query from the console, as a user of the installation (anonymous unless --as names one), and print the answer.

Download as PDF

Address: https://doc.exponential.earth/learninminutes/exphelp/viewer/examples/commands/expgraphqlquery.md

On this page

exp:expgraphqlquery

Run a GraphQL query from the console, as a user of the installation (anonymous unless --as names one), and print the answer.

Script bin/php/expgraphqlquery.php, code in kernel/private/classes/commands/expgraphqlquery.php. Run it from the installation root, as the user the web server runs as:

./console exp:expgraphqlquery --help
./console exp:graphql:query --help
php bin/php/expgraphqlquery.php --help

Help text

Run a GraphQL query and print the answer
The query is the argument, or a file of it (a path ending in .graphql or .gql, or - for standard
input). It runs in the siteaccess of --siteaccess with the rights of the user of --as (a login),
else as the anonymous user; the console may always read the schema (introspection). The API need
not be switched on.

./console exp:graphql:query '{ node(id: 2) { name children { totalCount } } }'
./console exp:graphql:query queries/menu.graphql --variables='{"depth": 2}' --as=admin
./console exp:graphql:query '{ siteaccess { name schemaHash } }' --format=table
./console exp:graphql:query --id=articles     a persisted query, by its name or its SHA-256

Exit code: 0 an answer without errors; 1 an answer with errors; 3 the library is missing;
2 wrong options (no query, variables not JSON, an unknown user).

Options

OptionValueHelp
--variablesrequiredthe variables, a JSON object
--operationrequiredthe operation to run when the query has several
--asrequiredrun as this user (a login); default: anonymous
--formatrequiredjson (the default) or table (one line per value: its path and the value)
--idrequiredrun the persisted query of this name or SHA-256 instead of a query text

Read from the option definitions in the code (startup(), getOptions(), options() or ezcConsoleOption). Every script also takes the standard options of the script framework (--help, --siteaccess, --debug, --quiet, --allow-root-user ...).

Arguments: [query].


Generated by ./console exp:help:examples from bin/php/expgraphqlquery.php, kernel/private/classes/commands/expgraphqlquery.php. Do not edit this page: change the source and generate again (how). Free documentation: GFDL 1.3 or later.

Something wrong on this page? Report an error

Documentation license

This documentation is free documentation, licensed under the GNU Free Documentation License 1.3 or later.

Exponential Copyright © 1998-2026 Exponential Foundation and 7x