graphql-editor / Gql

Licence: mit
Very simple CLI for many GraphQL schemas in the cloud. Provides autocompletion for GraphQL queries

Programming Languages

go
31211 projects - #10 most used programming language

Projects that are alternatives of or similar to Gql

Graphqurl
curl for GraphQL with autocomplete, subscriptions and GraphiQL. Also a dead-simple universal javascript GraphQL client.
Stars: ✭ 3,012 (+2882.18%)
Mutual labels:  graphql, cli, curl, autocomplete
Caporal.js
A full-featured framework for building command line applications (cli) with node.js
Stars: ✭ 3,279 (+3146.53%)
Mutual labels:  cli, terminal, autocomplete
Graphql Cli
📟 Command line tool for common GraphQL development workflows
Stars: ✭ 1,814 (+1696.04%)
Mutual labels:  graphql, cli, terminal
Tsukae
🧑‍💻📊 Show off your most used shell commands
Stars: ✭ 345 (+241.58%)
Mutual labels:  cli, terminal, command
Jquery.terminal
jQuery Terminal Emulator - JavaScript library for creating web-based terminals with custom commands
Stars: ✭ 2,623 (+2497.03%)
Mutual labels:  cli, terminal, command
Covid19 Tracker Cli
A curl-based command line tracker for Novel Coronavirus or COVID-19 pandemic. It Supports terminal for linux and macos, command prompt for windows, and termux for android with real-time updates.
Stars: ✭ 244 (+141.58%)
Mutual labels:  cli, terminal, curl
Nestjs Console
A nestjs module that provide a cli to your application.
Stars: ✭ 284 (+181.19%)
Mutual labels:  cli, terminal, command
Curlie
The power of curl, the ease of use of httpie.
Stars: ✭ 877 (+768.32%)
Mutual labels:  cli, terminal, curl
Cheat.sh
the only cheat sheet you need
Stars: ✭ 27,798 (+27422.77%)
Mutual labels:  cli, terminal, curl
Autocomplete
Autocomplete for terminals on MacOS
Stars: ✭ 569 (+463.37%)
Mutual labels:  cli, terminal, autocomplete
Simplecli
Command Line Interface Library for Arduino
Stars: ✭ 135 (+33.66%)
Mutual labels:  cli, command, line
Crossline
A small, self-contained, zero-config, MIT licensed, cross-platform, readline and libedit replacement.
Stars: ✭ 53 (-47.52%)
Mutual labels:  cli, terminal, autocomplete
Typin
Declarative framework for interactive CLI applications
Stars: ✭ 126 (+24.75%)
Mutual labels:  cli, terminal, command
Httpie
As easy as /aitch-tee-tee-pie/ 🥧 Modern, user-friendly command-line HTTP client for the API era. JSON support, colors, sessions, downloads, plugins & more. https://twitter.com/httpie
Stars: ✭ 53,052 (+52426.73%)
Mutual labels:  cli, terminal, curl
Rate.sx
💰 curl cryptocurrencies exchange rates
Stars: ✭ 563 (+457.43%)
Mutual labels:  cli, terminal, curl
Influx Prompt
An interactive command-line InfluxDB cli with auto completion.
Stars: ✭ 42 (-58.42%)
Mutual labels:  cli, terminal, autocomplete
Http Prompt
An interactive command-line HTTP and API testing client built on top of HTTPie featuring autocomplete, syntax highlighting, and more. https://twitter.com/httpie
Stars: ✭ 8,329 (+8146.53%)
Mutual labels:  cli, terminal, autocomplete
Vcli
Vertica CLI with auto-completion and syntax highlighting
Stars: ✭ 75 (-25.74%)
Mutual labels:  cli, autocomplete
Navi
An interactive cheatsheet tool for the command-line
Stars: ✭ 10,055 (+9855.45%)
Mutual labels:  cli, terminal
Cognitocurl
🦉🤖Easily sign curl calls to API Gateway with Cognito authorization token.
Stars: ✭ 76 (-24.75%)
Mutual labels:  cli, curl

GraphQL CLI

About

Without going too much into details, I was lately working on some integration of one of our GraphQL projects and had to write a simple internal tooling script for some simple tasks.

Now, I love curl as much as a next guy, it is my first goto tool when I need to do some debugging with anything related to REST/GraphQL/HTTP(S) in general but stil, writing

$ curl -X POST -g -H "Authorization: bearer ${GITHUB_TOKEN}" -H "Content-Type: application/json" https://api.github.com/graphql -d '{"query": "query {viewer {issues(first: 1) {nodes{title}}}}"}

is a bit of a mouthful. Especially those brackets, I actually made a typo with backets while writing this example.

So my first though was, well I'll just write a simple CLI for that project, but with GraphQL and it's introspection, you can quite easily make an "one shoe fits all" kind of tool. And that's what this project tries to be.

Now, this project is very much WIP. Any and all contributions are welcome as long as a contributor remembers one thing, the aim of this tool is not to be a robust and flexible GraphQL client that creats specialized and optimized GraphQL queries. Nor is it a tool meant to help with writing/deployment/whatnot of GraphQL schema for project. It's goal is to make a simple and convenient CLI for most schemas that already exist somewhere upstream. It's meant to be used mostly while scripting and debugging. So usage>performance.

It's quite small (~3000 lines) and comes with (almost finished) completion to boot.

sample

Requirements

Build

  • Go version 1.11 or higher

Installation

Latest release

$ sudo curl https://raw.githubusercontent.com/slothking-online/gql/master/getgql | sudo sh

From source

go get -u github.com/slothking-online/gql

Without root

$ curl https://raw.githubusercontent.com/slothking-online/gql/master/getgql | PREFIX=$HOME/bin sh

License

MIT

How It Works

The main idea is that there's "main" path to the field along which the tool is build the query. That is a bit against GraphQL ideology, as it limits the user's flexibility. Making it harder/more costly to get more complex data, but again, this tool is meant to be mostly developer tool for stuff like simple scripting,debugging and experimenting. That's why I decided it's better to just stick to simplicity rather than robustness and flexibility.

Most of functionality is self documenting (if possible pulling docs from schema). If there were no errors, unrelated to GraphQL, the data field of response will be written as JSON to stdout, while errors field to stderr.

For example

$ gql query --endpoint https://countries.trevorblades.com/ --help

will return

<snip>

Usage:
  gql query [flags]
  gql query [command]

Available Commands:
  continent   continent(code: String): Continent
  continents  continents: Continent
  countries   countries: Country
  country     country(code: String): Country
  language    language(code: String): Language
  languages   languages: Language

Flags:
      --endpoint string      graphql endpoint
      --fields stringArray   additional fields to resolve aside from the next one in resolve path
      --format string        go template response formatting
      --header Header        set header to be passed in a http request, can be set multiple times (default {})
  -h, --help                 help for query
      --max-depth int        resolve this field up to max-depth
      --no-cache             do not cache schema introspection result

Use "gql query [command] --help" for more information about a command.

So if we want to pull currency in country, for example in united states, we would do something like this:

$ gql query --endpoint https://countries.trevorblades.com/ country --arg-code US currency

which would give us

{
    "country": {
        "currency": "USD,USN,USS"
    }
}

This is not exactly useful in scriptting, as parsing json in bash is not exactly fun (unless you're using jq, but that's another dependency to install). We can refine it using Go Templates

gql query --endpoint https://countries.trevorblades.com/ country --arg-code US currency --format '{{.country.currency}}'

and then we get

USD,USN,USS

Docs

WIP

Contribute

  1. Fork this repo
  2. Create your feature branch: git checkout -b feature-name
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request

TODO

  • Tests for all of commands
  • --fields option on each node in path to include additional fields in response
  • Missing GraphQL features such as depracation and subscription (using websockets)
  • Some serious refactoring on cmd package with goal of embedding the command in custom tools.
  • Documentation for subscription and mutation
  • Cache improvements, right now it's just a simple serialized json
  • Completion improvements (right now completion, won't event hint query,mutation and subscription until endpoint path is provided)
  • ZSH completion
  • Profiles, typing --endpoint with url each time is annoying
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].