gurl graphql

Execute a GraphQL query against an endpoint.

Usage

gurl graphql [flags]

Description

The graphql command sends GraphQL queries to an endpoint. You can provide the query inline, from a file, with variables, and control output formatting.

Flags

FlagShortDefaultDescription
--query-qnoneGraphQL query string
--query-file-fnonePath to file containing GraphQL query
--vars-vnoneVariables as JSON
--operation-namenoneGraphQL operation name
--formatautoOutput format: auto, json, or table
--color-ctrueEnable colored output

Aliases

  • gql

Examples

Simple query

gurl graphql --query "{ users { id name } }" https://api.example.com/graphql

Sends a simple GraphQL query.

Query from file

gurl graphql --query-file ./query.gql https://api.example.com/graphql

Reads the query from a file.

Query with variables

gurl graphql -q "query($id: ID!) { user(id: $id) { name } }" --vars '{"id":"123"}' https://api.example.com/graphql

Sends a query with variables.

Named operation

gurl graphql --query-file ./queries.gql --operation-name "GetUser" https://api.example.com/graphql

Executes a specific named operation from a file with multiple queries.

See also