Skip to the content
Documentation

exp:expgraphqlquery

No ratings yet

Available since Exponential 6.0.15 (in development, not in a release yet).

Summary

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

Usage

./console exp:expgraphqlquery [options]
php bin/php/expgraphqlquery.php [options]
./console exp:graphql:query [options]

Aliases

exp:graphql:query

Help

The output of ./console help exp:expgraphqlquery (the script run with --help), without the standard options:

Usage: bin/php/expgraphqlquery.php [OPTION]... [QUERY]
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:
  --variables=VALUE  the variables, a JSON object
  --operation=VALUE  the operation to run when the query has several
  --as=VALUE         run as this user (a login); default: anonymous
  --format=VALUE     json (the default) or table (one line per value: its path and the value)
  --id=VALUE         run the persisted query of this name or SHA-256 instead of a query text

Options

Option Value Description
--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

Arguments

[query]

Standard options

Every script also takes the standard options of the script framework: --help, --quiet, --siteaccess, --debug, --colors, --no-colors, --logfiles, --no-logfiles, --verbose and --allow-root-user.

Source

bin/php/expgraphqlquery.php, kernel/private/classes/commands/expgraphqlquery.php

See also

Generated example: exp:expgraphqlquery

Added to the reference for Exponential 6.0.15.

Contributors

Comments

Add a comment

Comments are read by a moderator before they appear.