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

Controls

  • Navigate with arrow keys.

  • Select fields with <Space>.

  • Toggle between argument selection and its value with <Tab>.

  • End with <Enter>.

Examples

Set default GraphQL endpoint:

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

Interactively create a query and execute it:

$ gqt
{
    "statistics": {
        "numberOfGraphqlRequests": 3
    }
}

Repeat last query:

$ gqt -r
{
    "statistics": {
        "numberOfGraphqlRequests": 4
    }
}

Print the query instead of executing it:

$ gqt -q
{statistics {numberOfGraphqlRequests}}

Use jq for colors and extracting field values:

$ gqt | jq
{
  "statistics": {
    "numberOfGraphqlRequests": 5
  }
}
$ gqt | jq .statistics.numberOfGraphqlRequests
6

Alternatively use and bat for colors:

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

Use YAML output and bat for colors:

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

Print the schema:

$ gqt --print-schema | bat -l graphql
───────┬────────────────────────────────────────────
        STDIN
───────┼────────────────────────────────────────────
   1    type Query {
   2      standardLibrary: StandardLibrary!
   3      statistics: Statistics!
   4      activities: [Activity!]!
   5    }
   6   
   7    type StandardLibrary {
   8      package(name: String!): Package!
   9      packages: [Package!]
  10      numberOfPackages: Int
  11      numberOfDownloads: Int
  12    }
  ...

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
    │ ▼ standardLibrary
    │   ▼ package
    │     $ name: name
    │     ■ id: 5
    │     $ kind: kind
    │     □ name
    │   □ numberOfDownloads
    │ ▶ 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.47.0.tar.gz (9.3 kB view details)

Uploaded Source

Built Distribution

gqt-0.47.0-py3-none-any.whl (8.6 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for gqt-0.47.0.tar.gz
Algorithm Hash digest
SHA256 d590afaac8f466f3437ded301223b215e21686d59754d736292d4eed709abdb2
MD5 d1cbd63d40063daa70b01414999b2506
BLAKE2b-256 8d2fa1841746c455a8741ea2f72455afc2368a680ff2d6408699fe6bd003d188

See more details on using hashes here.

File details

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

File metadata

  • Download URL: gqt-0.47.0-py3-none-any.whl
  • Upload date:
  • Size: 8.6 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.47.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b48d120d013cab1c7de52d7467dc6843116d6b6a44b5456cad23ecd2c3704f61
MD5 90e58f755c5ae0d2b6cfcb2418567197
BLAKE2b-256 1bbe414c2d1a37c24be650c7ff0614ea70e760c6811b555f1d09c363fbe5f014

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