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

grql

v0.3.5

Published

GraphQL client command line

Downloads

7

Readme

NPM version Build Status Coverage Status npm

GraphQL client command line

Simple command line to query any GraphQL servers.

  • Sample default configuration with GraphQLHub server endpoint
  • Supports basic auth, fragments and mutations

Installation

$ npm install grql -g

Install a bundled version to $HOME/bin :

$ npm run installbin

Configuration

The configuration is stored into $HOME/.grql.yml, including environments settings and named queries.

Usage

Show help :

$ grql --help

Example of query : get a Giffy image from GraphQLHub

$ grql query '{ giphy { random(tag:"superbike") { url } } }'

Result :

{
  "giphy": {
    "random": {
      "url": "http://giphy.com/gifs/rhmit-xKi2gX2tY7h3q"
    }
  }
}

Use YAML output format :

$ grql query '{ giphy { random(tag:"superbike") { url } } }' -y

Result :

giphy: 
  random: 
    url: http://giphy.com/gifs/gtr-UUWYxAvgO60X6

Show configured environments :

$ grql -e
environnements :
[ ] graphqlhub
[o] myenv
[ ] anotherenv

Specify your own graphql server :

$ grql --baseurl https://mysupergraphql.server/graphql query "{ myquery(foo: "bar") }"

Save own graphql server to a named configuration :

$ grql --baseurl https://mysupergraphql.server/graphql \
  --conf mysuperserver --save \
  query '{ myquery(foo: "bar") }'

Save a query :

$ grql --alias myquery query '{ myquery(foo: "bar") }' --save

Next, to replay the query :

$ grql --alias myquery query

Query

The query content is passed either by command argument :

$ grql query '{ contact { username: "jdoe"} }'

or by stdin :

$ echo '{ contact { username: "jdoe"} }' | grql query 

Fragments

Save a new fragment :

$ cat << EOM | grql fragment gifInfo -s
fragment on GiphyGIFData {
  id
  url
  images {
    original {
      url
    }
  }
}
EOM

Use it in a query :

$ grql query '{ giphy { random(tag:"superbike") { ...${gifInfo} } } }' -y

Mutations

Change my details with my contacts graphql server :

$ cat << EOM | grql -e contacts mutate
{
  patchMe(input: {firstName: "John", lastName: "Doe"}) {
    id
    firstName
    lastName
    email
    username
  }
}
EOM

Switches

  • verbose : show more details
  • dryrun : does not finally execute the query
  • env : show current environment or select the specified environment
  • nocolor : disable color mode
  • alias : select an alias to save or play
  • save : save options to current environment
  • yaml : enable YAML output format
  • var : inject a variable (format key=value)

Enjoy!