-
Notifications
You must be signed in to change notification settings - Fork 479
Run GraphQL requests from CLI
Run a single GraphQL script from a file using the built-in CLI in CloudBeaver
- make sure the server container is running
- have an API access token
- prepare a file with exactly one GraphQL operation, save it in any format (such as
.json
or.txt
), and make sure the content is validJSON
Tip: with Docker Compose, either mount the script file or a folder of scripts into the service container at startup, or copy the file into the running container.
Create a JSON file with query
, variables
, and operationName
. For schema details and more operations, see GraphQL
API overview.
Example:
{ "query": "mutation createConnection($projectId: ID!, $config: ConnectionConfig!) { connection: createConnection(projectId: $projectId, config: $config) { ...DatabaseConnection } } fragment DatabaseConnection on ConnectionInfo { id projectId name }", "variables": { "projectId": "g_GlobalConfiguration", "config": { "configurationType": "MANUAL", "credentials": { "userPassword": "qwe", "userName": "qwe" }, "mainPropertyValues": { "host": "localhost", "port": "3306" }, "networkHandlersConfig": [], "providerProperties": {}, "driverId": "mysql-ee:mysql8", "name": "MySQL@localhost", "host": "localhost", "port": "3306", "databaseName": null, "authModelId": "native", "properties": {} } }, "operationName": "createConnection" }
For more ready-to-run examples, see the CloudBeaver graphql examples repository.
Open a shell in the Compose service container:
docker compose exec <service_name> bash
List services, and get the container id for a service:
docker compose ps
docker compose ps -q <service_name>
Copy your script from the host into the service container:
docker cp /path/on/host/create-connection.json $(docker compose ps -q <service_name>):/tmp/create-connection.json
Tip: if you use the older v1 CLI, replace
docker compose
withdocker-compose
.
Run the command:
docker compose exec <service_name> ./server-cli.sh \
-input-file /tmp/create-connection.json \
-gql \
-access-token <your_api_token>
-
-input-file
- path to the script file inside the container -
-gql
- runs the file as a GraphQL request -
-access-token
- your API token string
The command prints the GraphQL response to stdout in JSON
, including data
, and, if present, errors
.
By default, the server CLI prints the GraphQL response to stdout.
If you want to save the response into a file inside the container, use the -output-file
option:
docker compose exec <service_name> ./server-cli.sh \
-input-file /tmp/create-connection.json \
-output-file /opt/cloudbeaver/workspace/out.txt \
-gql \
-access-token <your_api_token>
-
-output-file
- path to the output file inside the container. The server CLI writes the GraphQL response to this file.Tip: Not every path inside the container is valid for writing. A safe location is
/opt/cloudbeaver/workspace/
.
If you run CloudBeaver on AWS, do the same steps inside the instance: place
the JSON
file on the instance, then run the CLI there.
For connection and file transfer basics, see AWS documentation:
- Getting started
- Create connection
- Connection network options
- Supported databases
-
Drivers management
- Database authentication methods
- Database navigator
- Properties editor
- Data editor
- SQL editor
-
Entity relation diagrams
- Cloud services
-
AI Smart assistance
- Data transfer
- General user guide
- Administration
- Server configuration
-
Server security and access configuration
- Authentication methods
- Access management
- Proxy configuration
-
Secret management
- Logs
-
Query manager
- Workspace location
- Command line parameters
-
Session manager
- Deployment options
- CloudBeaver Editions
- FAQ
- Development