Skip to content

tool to make rest and graphql calls from command line or from your editor itself

Notifications You must be signed in to change notification settings

nxtcoder17/http-cli

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

http client to speed up GraphQL/rest api development

demo

How to Use (with neovim)

  • if you use packer
  use({
    "nxtcoder17/http-cli",
    run = "pnpm i",  -- npm i, as per your choice
    config = function()
      require("http-cli").setup()
    end,
  })
  • default config
local defaultConfig = {
	command = "Gql",
	envFile = function()
		return string.format("%s/%s", vim.env.PWD, "gqlenv.yml")
	end,
}

How to Use

  • You should create a gqlenv.yml file in your project root directory, something like this
mode: dev
map:
  dev:
    url: <endpoint>
    headers:
      k1: v1
      k2: v2
  • then, create a file $filename.yml file
# filename: auth-graphql.yml
---
global:
  email: "sample@gmail.com"

---
query: |
  mutation Login($email: String!, $password: String!) {
    auth {
      login(email: $email, password: $password) {
        id
        userId
        userEmail
      }
    }
  }

variables:
  email: "{{email}}" # this is variable parsing, from either 'gqlenv.json' or from 'global' doc at the top
  password: "hello"  
  • now, execute it
go run ./main.go -- $filename $envFileName $lineNumber
  • you need to have a variable url either in one of the mode vars or global vars

Inspired By

.http file based REST Client in Neovim/vim and Intellij

Next To Come

  • Neovim plugin that could just setup the previous step for you
  • i don't know yet 😂

About

tool to make rest and graphql calls from command line or from your editor itself

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published