8000 GitHub - nanderoo/gqt: Build and execute GraphQL queries in the terminal.
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

nanderoo/gqt

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GraphQL client in the terminal

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
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 very well.
  • Fragments and unions are not implemented.
  • Mutations and subscriptions are not implemented.
  • And much more.

Ideas

  • Show GraphQL API documentation.

  • 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

  • Mutations?

  • Subscriptions?

  • Arguments and variables:

    For required arguments with default value:

    □: omit
    ■: non-null value
    $: 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]
    

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

About

Build and execute GraphQL queries in the terminal.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 99.5%
  • Makefile 0.5%
0