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

troveql

v0.1.7

Published

caching solution for graphQL

Downloads

1

Readme

Features

  • Server-side cache for GraphQL queries using the Advanced Replacement Cache (ARC) algorithm
  • Custom cache configurations with options such as total capacity
  • Cache invalidation logic on GraphQL mutations
  • Support for Node.js/Express.js servers
  • Cache performance monitoring with key metrics such as Hit/Miss Rate and Query Response Time

Documentation

Visit our website to get more information and watch a demo of TroveQL and its performance monitoring application TroveMetrics.

Table of Contents

Install TroveQL

Install the Express library via npm

npm install troveql

Set up TroveQL in Express

  1. Import TroveQLCache
const { TroveQLCache } = require('troveql');
  1. Set up your TroveQL cache
const capacity = 5; // size limit of your cache
const graphQLAPI = 'http://localhost:4000/graphql'; // your graphQL URL endpoint
const useTroveMetrics = true; // (optional) if you would like to use TroveMetrics - default is false
const mutations = {}; // (optional) object where key/value pairs are mutation types/object types mutated (ex. { addMovie: 'movie', editMovie: 'movie', deleteMovie: 'movie' })
const cache = new TroveQLCache(capacity, graphQLAPI, useTroveMetrics, mutations);
  1. Add the /troveql and, if applicable, /trovemetrics endpoints
// REQUIRED
app.use(express.json())
app.use(express.urlencoded({ extended: true }));

// /troveql to use the cache
app.use('/troveql', 
  cache.queryCache,
  (req: Request, res: Response) => res.status(200).json(res.locals.value)
);

// /trovemetrics to clear the cache from TroveMetrics
app.use('/trovemetrics', 
  cache.troveMetrics,
  (req: Request, res: Response) => res.status(200).json(res.locals.message)
);
  1. Add your GraphQL endpoint. For example:
const { graphqlHTTP } = require("express-graphql");
const { schema } = require('./schema');
const { resolvers } = require('./resolvers');

app.use('/graphql', 
  graphqlHTTP({
    schema: schema, 
    rootValue: resolvers,
    graphiql: true
  })
);
  1. To use TroveMetrics to monitor the performance of your cache and GraphQL API on your application's server, you can go to our website and download the desktop application for your OS (macOS, Windows, Linux).

Query or Mutate your GraphQL API

Simply send a request to your GraphQL API for queries and mutations as you normally would. For example, a query with variables using the fetch syntax could look like:

fetch('/troveql', {
  method: 'POST',
  headers: { 
    'Content-Type': 'application/json' 
  },
  body: JSON.stringify({
    query: `query ($id: ID) {
      movie(id: $id) {
          id
          title
          genre
          year
          actors 
            {
              name
            }
      }
    }`,
    variables: { id: 10 }
  })
})
.then(response => response.json())
.then(response => {
  // access the data on the response object with response.data
})

Iteration Roadmap

  • Client-side caching
  • Persistent queries to improve the performance and security of client queries to the server
  • Additional cache invalidation logic on mutations
  • Update cache capacity to reflect memory size (bytes) instead of number of items
  • User authentication for TroveMetrics

Contribution Guidelines

If you would like to contribute to this open-source project, please follow the steps below:

  1. Fork the repository from the dev branch
  2. Create a new feature branch (git checkout -b feature/newFeature)
  3. Commit your changes with a descriptive comment (git commit -m 'Added a new feature that ...')
  4. Push your changes to the new feature branch (git push origin feature/newFeature)
  5. Open a Pull Request on the dev branch
  6. We will review your PR and merge the new feature into the main branch as soon as possible!

Thank you so much!

Stack

  • GraphQL
  • Node.js / Express.js
  • Electron
  • React.js
  • Chart.js
  • Webpack
  • TypeScript
  • JavaScript
  • HTML
  • CSS / SASS
  • Jest

Authors

Alex Klein - GitHub | LinkedIn Erika Jung - GitHub | LinkedIn Sam Henderson - GitHub | LinkedIn Tricia Yeh - GitHub | LinkedIn

License

This project is licensed under the MIT License.