Skip to content
gurl graphql

gurl graphql

Send a GraphQL query or mutation to an endpoint, inline or from a file.

Synopsis

gurl graphql <endpoint> (--query <query> | --query-file <file>) [flags]

The endpoint argument is required, and so is one of --query or --query-file.

Flags

FlagShortDefaultDescription
--query-qnoneGraphQL query string
--query-file-fnonePath to a .graphql file containing the query
--vars-vnoneJSON object with query variables (e.g., '{"limit": 10}')
--operation-name--opnoneGraphQL operation name
--format--fmtautoOutput format: auto, json, table
--color-cfalseEnable syntax highlighting

Aliases

  • gql

Examples

Inline query

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

Query with variables

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

Named operation from a file

gurl graphql https://api.example.com/graphql --query-file ./queries.graphql --op GetUser

Related commands

  • gurl grpc - gRPC requests
  • gurl ws - WebSocket connections
  • gurl sse - Server-Sent Events
  • gurl save - Save an HTTP request (GraphQL over POST works as a saved request too)