npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

gest

v1.7.0

Published

GraphQL testing CLI

Downloads

40

Readme

Usage

$ npm install -g gest

then send queries with gest (pronounced guest [/ɡest/]).

$ gest [options] [query | pathToFileWithQuery]
Examples
$ gest '{ test }'

or

$ gest test.graphql

# with `test.graphql` containing
{
  test
}

or multiple

$ gest test.graphql '{ test }' introspection.graphql
# will run all three queries!

REPL

$ gest

Query: { test }

{
  data: {
    test: "success!"
  }
}

HTTP

If you specify a baseURL in your config, gest will send an POST request with your query correctly encoded in the body. Your baseURL must be a valid URL.

You can specify HTTP headers by using -H key=value flags.

This is especially convenient if you are using a Now workflow.

Example
$ gest -H Authorization=e130294e --baseURL https://test-server-2ae34342.now.sh '{ test }'

Local module

You can use gest as a local module in your unit/integration tests

Examples
const Gest = require('gest')
const schema = require('../src/schema')

const gest = Gest(schema, {
  baseURL: 'test-server.now.sh',
  headers: {
    Authorization: 'Bearer token',
    Accept: 'application/json'
  }
})

describe('GraphQL', () => {
  test('{ test }', () => {
    return gest('{ test }').then(({ data, errors }) => {
      expect(errors).toBeUndefined()
      expect(data).toEqual('success!')
    })
  })
})

or use Global gest with jest.

// will create global `gest()` function
Gest(schema)

// pass a test name and a query
gest(
  'test query',
  `
  {
    test
  }
`
)

Note: Global functionality will be turned on by default if NODE_ENV === test and if global.test or global.it exists

Flags

--all (-A)

Running gest --all will run all files matching *.query, *.graphql, or *.gql and simply print if each query succeeded without errors

--inspect (-I)

For convenience, running gest --inspect or gest -I will pretty print your GraphQL schema

--print (-P)

Pretty print your GraphQL queries (without using GraphiQL!)

$ gest [query | pathToQuery] --print
Example
$ gest '{test}' --print

{
  test
}
--schema (-S)

You can specify the path to your GraphQL schema with gest --schema ./path/to/schema.js

--baseURL (-B)

URL to send GraphQL queries to: gest --baseURL https://test-server.now.sh

--header (-H)

HTTP request headers to send with your queries: gest --header Accept=application/json. Headers will be passed into context as context.headers for every query for local testing.

Convention

The gest CLI will look to resolve your GraphQL schema in the current working directory for schema.js. If you wish to specify a different schema location, do so as schema in your config.

Config

You can configure the gest runtime by adding a gest key to your package.json, or specifying them as flags.

Example
// package.json
{
  "name": "your_package",
  ...
  "gest": {
    "schema": "./path/to/schema",
    "baseURL": "https://your.url.sh"
  }
}

Why gest?

Pros
  • :+1: No restarting your dev server when you make changes
  • :+1: Testing your schema doesn't require a separate window (e.g. Graphiql)
  • :+1: Run queries from files (save the queries you use most often)
  • :+1: Simple unit testing for your schema
  • :+1: Easy regression testing with gest --all.
  • :+1: Simple integration/deployment testing with --baseURL
  • :+1: Handy introspection and pretty printing
  • :+1: Helpful error messages!
Drawbacks
  • :-1: No query autocompletion (yet)

Contributing

  1. Fork this repository to your own GitHub account and then clone it locally
  2. Install the dependencies: npm install
  3. Run npm link to link the scripts found in bin for testing terminal commands
  4. Before submitting a pull request, run npm test

Need help?

Running gest help will show you all the gest options. If you have any other concerns, post an issue!

Logo

The official gest logo is designed by @jakedex

License

MIT