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

Name queries:

gqt -n stats -y
statistics:
  numberOfGraphqlRequests: 8
gqt -n time -y
standardLibrary:
  package:
    latestRelease:
      version: 0.20.0
gqt -n stats -y -r
statistics:
  numberOfGraphqlRequests: 9
gqt -n time -y -r
standardLibrary:
  package:
    latestRelease:
      version: 0.20.0

Make arguments variables by pressing v or $ and give them as -v <name>=<value> on the command line:

gqt -v name=time -y
standardLibrary:
  package:
    latestRelease:
      version: 0.20.0
gqt -r -q
query Query($name: String!) {
  standardLibrary {
    package(name: $name) {
      latestRelease {
        version
      }
    }
  }
}

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

  • Unions and interfaces are not implemented.

  • And much more.

Ideas

  • 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

  • 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.91.0.tar.gz (13.8 kB view details)

Uploaded Source

Built Distribution

gqt-0.91.0-py3-none-any.whl (14.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: gqt-0.91.0.tar.gz
  • Upload date:
  • Size: 13.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.91.0.tar.gz
Algorithm Hash digest
SHA256 33159c8e027fa4469ed6f2696d4814f30a50a14947ac39b2317bd483bac37497
MD5 7a85f1b739fab9365a7395e78e4010ea
BLAKE2b-256 22668268711d32a035486f9555a28f01dce6e9497588b109bea4c3c4ce780b29

See more details on using hashes here.

File details

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

File metadata

  • Download URL: gqt-0.91.0-py3-none-any.whl
  • Upload date:
  • Size: 14.2 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.91.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d2513321e8a3f04a482ef29546a9ee11af21aa779ab781a761f32b8c360cda21
MD5 bb74970bc24dcac150581f4a4b12e320
BLAKE2b-256 9890f46e642880442344c5df37317629b60d8d2ccdfbc9aa037767a20a64d485

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