Forem

Cover image for Graphqurl - curl like CLI for GraphQL
Tomek Poniatowicz for GraphQL Editor

Posted on

9 3

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,

Graphqurl

Source: hasura.io/blog/

Usage

Query


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

     -H 'Authorization: Bearer <token>' \

     -q 'query { table { column } }'

Enter fullscreen mode Exit fullscreen mode

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>

Enter fullscreen mode Exit fullscreen mode

GraphiQL

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


gq <endpoint> -i

Enter fullscreen mode Exit fullscreen mode

Subscription

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


gq <endpoint> \

   -q 'subscription { table { column } }'

Enter fullscreen mode Exit fullscreen mode

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 Graphqurl GitHub repo.


Speed up your GraphQL API development

GraphQL Editor is a supportive tool for both advanced GraphQL users as well as those taking their first steps with GraphQL APIs. Our all-in-one development environment for GraphQL will help you build, manage & deploy your GraphQL API much faster. Try GraphQL Editor for free!

New features of GraphQL Editor gif

Sentry blog image

How to reduce TTFB

In the past few years in the web dev world, we’ve seen a significant push towards rendering our websites on the server. Doing so is better for SEO and performs better on low-powered devices, but one thing we had to sacrifice is TTFB.

In this article, we’ll see how we can identify what makes our TTFB high so we can fix it.

Read more

Top comments (0)