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

@satsuma/cli

v1.1.119

Published

Satsuma's CLI for managing custom graphql queries.

Downloads

210

Readme

🍊Satsuma CLI

Satsuma's CLI for managing custom graphql queries.

Getting started

This CLI can be run entirely though npx. The get started, head to the folder where your subgraph lives and run:

npx @satsuma/cli init

This will initialize a .satsuma.json, and a folder called custom-queries/ in your project root. The .satsuma.json file stores non-sensitive metadata about your subgraph, and the custom-queries/ folder is where you can configure custom GraphQL.

Writing custom queries

After running init, you'll see that you now have three new files.

typeDefs.ts

This file should export typeDefs, a string containing your custom GraphQL type definitions. This will be merged with your subgraph's schema.

resolvers.ts

This file should export resolvers, an object containing your custom GraphQL resolvers for any added fields in typeDefs.

helpers.ts (optional)

This file should export helpers, an object containing any helper functions you want to use in your resolvers. This will be passed to your resolvers via the graphql context.

Note: You should not import any modules in this file, nor should you import helpers directly into resolvers. It will not work due to the sandbox environment in which your code is executed

Context

All resolvers are passed a context object as the third argument. This context object contains the following properties:

  • db: An object containing knex instances for each of your subgraph's databases.
    • db.entities: The database containing your subgraph's entities.
  • helpers: An object containing any helper functions you've defined in helpers.ts.

Resolvers & Helpers runtime

Resolvers and helpers are run in a node sandbox. This means that we've limited the modules you can use, as well as the limits on the amount of memory and time your code can consume.

  • Max Memory: 1gb
  • Max Runtime: 25 seconds
  • Allowed Modules:
    • lodash (available as _)
    • date-fns (available as dateFns)
    • uuid (available as uuid)
    • moment
    • rxjs
    • ramda (available as R)
    • validator (https://www.npmjs.com/package/validator)
    • console (in local env, this will redirect to your console)

Types

For those who want to work with typescript, you can run the following to generate schema.graphql and schema.ts files.

npx @satsuma/cli codegen -k {your deploy key} --subgraphName {your subgraph name} --subgraphVersion {your subgraph version}

These files will be generated in the custom-queries/ folder. The schema.ts file will contain typescript types that you can import and use in your custom resolvers & helpers.

Note: You should not manually edit types.ts.

Running Locally

When you're ready to test your changes locally, you can run the following command to deploy your custom queries to a local graph node.

npx @satsuma/cli local -k {your deploy key} --subgraphName {your subgraph name} --subgraphVersion {your subgraph version}

This will spin up a server on http://localhost:4000. If you visit that URL, you'll be greeted with Apollo Studio's GraphQL playground.

Deploying

When you're ready to deploy your custom queries to Satsuma, you can run the following command:

npx @satsuma/cli deploy -k {your deploy key} --subgraphName {your subgraph name} --subgraphVersion {your subgraph version}