Tomek Poniatowicz
6/1/2021
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 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](/graphql-playground) - 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.
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 } }'
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](https://github.com/OneGraph/graphiql-explorer 'GraphiQL Explorer') and [GraphiQL Code Exporter](https://github.com/OneGraph/graphiql-code-exporter 'GraphiQL Code Exporter').
If you want to read more about the project make sure to visit the Graphqurl GitHub repo.