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

  • Press h or ? for help.

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
query Query {
  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 for input types.

  • Unions and interfaces are not implemented.

  • And much more.

Ideas

  • Input example:

    ╭─ Query
    │ ▼ item
    │   ■ config:
    │     ■ unit: metric
    │     □ width:
    │   □ length
    │   □ weight
  • List argument example:

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

    Always query __typename.

    union SearchResult = Book | Author
    
    type Book {
      title: String!
    }
    
    type Author {
      name: String!
    }
    
    type Query {
      search(contains: String): [SearchResult!]
    }
    
    Unselected:
    
    ╭─ Query
    │ ▶ search
    
    Selected:
    
    ╭─ Query
    │ ▼ search
    │   ▶ Book
    │     ■ title
    │   ▶ Author
    │     ■ name
  • Alias?

    • Press a to create an alias.

    • Press d to delete an alias.

    smallPicture and mediumPicture are aliases of picture.

    ╭─ Query
    │ ▶ Book
    │   ▶ picture
    │   ▼ smallPicture: picture
    │     ■ width: 320
    │     ■ height: 240
    │   ▼ mediumPicture: picture
    │     ■ width: 800
    │     ■ height: 600
  • Check for schema modifications when starting. Do it in the background and notify the user if it was modified.

    New schema fetched from the server. Use it? y/n

  • Variables example:

    ╭─ Query
    │ ▼ standardLibrary
    │   ▼ package
    │     $ name: name
    │     ■ id: 5
    │     $ kind: kind
    │     □ name
    │   □ numberOfDownloads
    │ ▶ statistics
    
    ╭─ Variables
    │ name: time
    │ kind:
    │   [0] ■ a: bar
    │       ■ b: ne
    │       □ c:
    │   [1]
  • Print variables:

    $ gqt -v
    {"name": "foo", "kind": [{"a": "bar", "b": "ne"}]}
  • Subscriptions. Probably out of scope.

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

Uploaded Source

Built Distribution

gqt-0.74.0-py3-none-any.whl (12.7 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for gqt-0.74.0.tar.gz
Algorithm Hash digest
SHA256 97dd7e0ba74bf03fdf1ee0be1b6259368a8f0c1391a0df6bf3fab46d68bd52da
MD5 3b0ab6c2799ba960d07fd014d6ec0cf7
BLAKE2b-256 b2183d4a6373f416ab83d54af7f66067933a150c7c7321765b24d4dd6cf6ec61

See more details on using hashes here.

File details

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

File metadata

  • Download URL: gqt-0.74.0-py3-none-any.whl
  • Upload date:
  • Size: 12.7 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.74.0-py3-none-any.whl
Algorithm Hash digest
SHA256 751844115881839ab2a47754c1b3e2db3b1bf65dcda42ce323038eb34d66067a
MD5 b3cfd019f2957551bf1ab2998f5a006b
BLAKE2b-256 a9df951e2b0cf7b7b0f529031f0ff57e20ccf5e3f7a444260e9ddf16aa3b36e2

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