Log in to GraphQL Editor
Graphqurl - curl like CLI for GraphQL
Tomek

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

Power of typeof & typestyle in react apps
Artur Czemiel
Artur Czemiel
Power of typeof & typestyle in react apps
3 min read
over 5 years ago
5 React UI Libraries you need to check out in 2020
Tomek Poniatowicz
Tomek Poniatowicz
5 React UI Libraries you need to check out in 2020
3 min read
almost 4 years ago
Twitter clone with React XP and faker
Artur Czemiel
Artur Czemiel
Twitter clone with React XP and faker
5 min read
over 5 years 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