Log in to GraphQL EditorGet started
Graphqurl - curl like CLI for GraphQL

Tomek Poniatowicz

6/1/2021

Graphqurl - curl like CLI for GraphQL

The amazing growth of GraphQL is drawing more and more developers every year. Its public release sparked the creation of a vast set of open-source libraries, tools and clients with a shared goal to make working with GraphQL an enjoyable experience. One of them is Graphqurl.

Graphqurl

Graphqurl is a curl-like CLI for GraphQL that's developed and maintained by Hasura, a GraphQL-related company known for its graphql-engine & Hasura Cloud solution.

Its features include:

- CLI - a curl-like command-line interface for making GraphQL queries with autocomplete,

- Custom GraphiQL - allowing you to run a custom GraphiQL, where you can specify headers for your requests as well as run it locally against any given endpoint,

- Subscriptions support - Graphqurl supports GraphQL subscription over WebSockets.

Source: hasura.io/blog/

Usage

Query

gq https://my-graphql-endpoint/graphql \

 -H 'Authorization: Bearer <token>' \\

 -q 'query { table { column } }'

Auto-complete

Execute the command without providing a query string

$ gq <endpoint> [-H header:value]

Enter the query, use TAB to auto-complete, Ctrl+Q to execute, Ctrl+C to cancel

gql>

GraphiQL

Opening GraphiQL with a given endpoint which runs a custom GraphiQL where you can specify request's headers

gq <endpoint> -i

Subscription

Subscriptions can be executed and the response is streamed on to standard output

gq <endpoint> \

   -q 'subscription { table { column } }'

Version 1.0

Recently a version 1.0 was released which introduced a couple of optimizations and improvements including:

- Reduced bundle size - previous CLI versions used Apollo client for making GraphQL queries & subscriptions which had a heavy impact on its bundle size, now Apollo was replaced by light-weight isomorphic HTTP clients which reduced the size by half!

- Custom GraphiQL - from version 1.0 custom graphiQL supports GraphiQL Explorer and GraphiQL Code Exporter.

If you want to read more about the project make sure to visit the Graphqurl GitHub repo.

Check out our other blogposts

Unlocking the Power of React 19
Tomasz Gajda
Tomasz Gajda
Unlocking the Power of React 19
1 min read
about 1 month ago
Zeus update - GraphQL spread operator
Michał Tyszkiewicz
Michał Tyszkiewicz
Zeus update - GraphQL spread operator
1 min read
3 months ago
What is GraphQL Zeus?
Michał Tyszkiewicz
Michał Tyszkiewicz
What is GraphQL Zeus?
1 min read
3 months ago

Ready for take-off?

Elevate your work with our editor that combines world-class visual graph, documentation and API console

Get Started with GraphQL Editor