Skip to content

ulisses-cruz/gql.nvim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gql.nvim

Simple graphql client for Neovim

Screenshot of gql.nvim plugin

Inspired by rest.nvim

Dependencies

This plugin uses curl to send the requests. You need to have curl installed in your system. It uses treesitter to identify the queries. You need treesitter installed in your neovim instance and the graphql parser.

:TSInstall graphql

Instalation

Via Packer

use 'ulisses-cruz/gql.nvim'

Configuration

Via Packer

use {
  'ulisses-cruz/gql.nvim',
  config = function()
    require 'gql'.setup {
      filetypes = { 'graphql' },
      keymaps = {
        run = '<leader>rr'
      }
    }
  end
}

There are only to configuration options for now:

  • filetypes: A list of file types the plugin shoul attach to. Defaults to { 'graphql' }.
  • keymaps: A table of action/keymap pairs. Currently there's only the run action. It has no default keymap.

Usage

  1. Go to a graphql file where you have your queries;
  2. Put the cursor on the query you what to run (not the query metadata);
  3. press the keymap you set in your configuration;

You should be prompt to enter the endpoint the query should be sent to. After entering the endpoint a split window should open to show the query response.

If you don't want to enter the endpoint every time, add it as a metadata to the query. You can do that by adding # endpoint: <your-endpoint> above the query.

# endpoint: https://countries.trevorblades.com/
{
  countries {
    code
    name
  }
}

You can also configure a default endpoint for all queries in the file, by adding the metadata as the first line of the file. The metadata added above each query has precedence.

# endpoint: https://countries.trevorblades.com/

{
  countries {
    code
    name
  }
}

query Country($code: ID!) {
  country(code: $code) {
    code
    name
  }
}

If your query requires any variable, you can set them as metadata also:

# variables: {
#   "code": "CV"
# }
query Country($code: ID!) {
  country(code: $code) {
    code
    name
  }
}

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages