Skip to main content

GraphQL client in the terminal.

Project description

This project is inspired by https://graphiql-online.com.

https://github.com/eerimoq/gqt/raw/main/docs/assets/showcase.gif

Installation

$ pip3 install gqt

Usage

Set default GraphQL endpoint URL:

$ export GQT_ENDPOINT=https://mys-lang.org/graphql

Interactively create a query and execute it:

$ gqt
{"statistics": {"number_of_graphql_requests": 234}}

Repeat last query:

$ gqt -r
{"statistics": {"number_of_graphql_requests": 235}}

Print the query instead of executing it:

$ gqt -q
{"query":"{statistics {number_of_graphql_requests}}"}

Use jq for indentation, colors and extracting field values:

$ gqt | jq
{
  "statistics": {
    "number_of_graphql_requests": 236
  }
}
$ gqt | jq .statistics.number_of_graphql_requests
237

Alternatively use json_pp and bat for indentation and colors:

$ gqt | json_pp | bat -l json
───────┬──────────────────────────────────────────────────────────────
        STDIN
───────┼──────────────────────────────────────────────────────────────
   1    {
   2       "statistics" : {
   3          "number_of_graphql_requests" : 238
   4       }
   5    }
───────┴──────────────────────────────────────────────────────────────

Use YAML output and bat for indentation and colors:

$ gqt -y | bat -l yaml
───────┬──────────────────────────────────────────────────────────────
        STDIN
───────┼──────────────────────────────────────────────────────────────
   1    statistics:
   2      number_of_graphql_requests: 239
───────┴──────────────────────────────────────────────────────────────

Known issues

  • Arguments does not work very well.

  • Scrolling.

Ideas

  • Mutations?

  • Subscriptions?

  • Arguments and variables:

    ■: not null
    □: null
    $: variable

    Scalar example:

    ╭─ Query
    │ ▼ standard_library
    │   ▼ package
    │     ■ name: ""
    │     □ name
    │   ▶ packages

    List example:

    ╭─ Query
    │ ▼ item
    │   □ kinds:
    │   ■ kinds2:
    │     [0] ■ a: "foo"
    │         ■ b: "eq"
    │         ■ c:
    │           [0] ■ a: "x"
    │               ■ b: "y"
    │           [1]
    │     [1] ■ a: "bar"
    │         ■ b: "ne"
    │         □ c:
    │     [2]

    Variables example:

    ╭─ Query
    │ ▼ standard_library
    │   ▼ package
    │     $ name: name
    │     ■ id: 5
    │     $ kind: kind
    │     □ name
    │   □ number_of_downloads
    │ ▶ statistics
    
    ╭─ Variables
    │ name: "foo"
    │ kind:
    │   [0] ■ a: "bar"
    │       ■ b: "ne"
    │       □ c:
    │   [1]

    Print the variables:

    $ gqt -v
    {"name": "foo", "kind": [{"a": "bar", "b": "ne"}]}

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gqt-0.43.0.tar.gz (8.8 kB view details)

Uploaded Source

Built Distribution

gqt-0.43.0-py3-none-any.whl (8.4 kB view details)

Uploaded Python 3

File details

Details for the file gqt-0.43.0.tar.gz.

File metadata

  • Download URL: gqt-0.43.0.tar.gz
  • Upload date:
  • Size: 8.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.13

File hashes

Hashes for gqt-0.43.0.tar.gz
Algorithm Hash digest
SHA256 3f70043843611851278df8fc9ab561fcbda22d85bd930ad36f87e5eecd4138c2
MD5 77b16db1b5ef3d669ea6319978cb5c23
BLAKE2b-256 9c75e8ac3e7067ed39b730571f0dfa45b0da159954b923680891071c10fe13a9

See more details on using hashes here.

File details

Details for the file gqt-0.43.0-py3-none-any.whl.

File metadata

  • Download URL: gqt-0.43.0-py3-none-any.whl
  • Upload date:
  • Size: 8.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.13

File hashes

Hashes for gqt-0.43.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6f79b6ec4ca5c829ec51c2df07f52c07c7c95041a524a51a45aab2a1dfcb06d5
MD5 aa3a194e1a2dc6a4206f8ac036334659
BLAKE2b-256 a88e682bf6d4885085f083e96534ac8bca1055d15a139f0b870b7841ddaa800f

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page