11 April 2018

Install

Look up and install Requester package from the sublime-text Package Control repos.

Configure

  • Create a directory to install Python packages for general use. I’ll assume you have exported it to $MY_FAV_PY_DIR

  • Install pipenv

cd $MY_FAV_PY_DIR
pipenv shell

Install supporting packages

pipenv install requests-oauthlib
pipenv install requests-toolbelt
pipenv install graphql-py

That should drop you into a Python 3 virtual environment and install the required packages. Get the virtualenv’s path with the following command:

pipenv --venv

And perform a command look-up to open Requester: Settings using cmd+shift+p. Insert the path as packages_path. The end result should look like this:

{
  "packages_path": "/Users/hashnuke/.local/share/virtualenvs/python-playground-hORFTXhj"
}

Test the setup

Head to https://launchpad.graphql.com and create a GraphQL bin. Requires login via GitHub to “save” a bin for yourself, with a unique URL. Once logged in, find the GraphQL endpoint mentioned at the bottom of the screen. Copy that.

In SublimeText, open a new tab and type this out (change the graphql endpoint appropriately)

requests.post('https://w5j3wpr1rz.lp.gql.zone/graphql', gql="""
{
  hello
}
""")

Press ctrl+r OR look-up the command Requester: Run Requests. That should open a new tab for the response.

GraphQL Schema

Open up the response tab after making a GraphQL request, ensure to create a new line and then press ctrl+space to get possible completions. The schema suggestions window will look something like this:

Ideally it should be able to complete a partial word too, but I guess that is a bugfix for another day. This will suffice for today.

More stuff?

  • The OAuth lib was installed to help make authenticated requests, like with the GitHub GraphQL API.
  • Everything there is just Python and the requests package. Check the requests website on passing headers and more.

Checkout the Requester website for a lot more features.