Skip to main content

GraphQL client in the terminal.

Project description

Build and execute GraphQL queries in the terminal.

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

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

Installation

pip3 install gqt

It’s recommended to install bat for pretty output.

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}}

YAML output:

$ gqt -y
statistics:
  numberOfGraphqlRequests: 8

Print the schema:

$ gqt --print-schema
type Query {
  standardLibrary: StandardLibrary!
  statistics: Statistics!
  activities: [Activity!]!
}

type StandardLibrary {
  package(name: String!): Package!
  packages: [Package!]
  numberOfPackages: Int
  numberOfDownloads: Int
}
...

Known issues

  • Arguments does not work very well.

  • Fragments and unions are not implemented.

  • Mutations and subscriptions are not implemented.

  • And much more.

Ideas

  • Show GraphQL API documentation.

  • Mutations?

  • Subscriptions?

  • Arguments and variables:

    For required arguments without default value:

    ■: non-null value
    $: variable

    For required arguments with default value:

    □: omit
    ■: non-null value
    $: variable

    For optional arguments:

    □: omit
    ■: non-null value
    $: variable
    n: null

    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]

    Input example:

    ╭─ Query
    │ ▼ item
    │   ■ config:
    │     ■ unit: "metric"
    │     □ width:
    │   □ length
    │   □ weight

    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.54.0.tar.gz (9.1 kB view details)

Uploaded Source

Built Distribution

gqt-0.54.0-py3-none-any.whl (9.1 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for gqt-0.54.0.tar.gz
Algorithm Hash digest
SHA256 d4c45b6653784c3c8ea2b342011f79e70c7f10686639e786725310c8e7bcd305
MD5 14d043a3d233b70ccb0f2e060c6a35fb
BLAKE2b-256 ab45f930536b15142394545e2d0482f269a3bf2efa87b90be15c55c30402a59d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: gqt-0.54.0-py3-none-any.whl
  • Upload date:
  • Size: 9.1 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.54.0-py3-none-any.whl
Algorithm Hash digest
SHA256 cd971efff42e21b39485da459a99d3d0613362ab54121d261518b9bdd7d4433b
MD5 220f684deb8db4d47e190ae974f15536
BLAKE2b-256 7ef112fb904bc7815b35ca7e5a98cbc840ad36314dceee821ee8d75b595925f2

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