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 --helpHelp 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
| Option | Value | Help |
|---|---|---|
--variables | required | the variables, a JSON object |
--operation | required | the operation to run when the query has several |
--as | required | run as this user (a login); default: anonymous |
--format | required | json (the default) or table (one line per value: its path and the value) |
--id | required | run 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].
Related
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.