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

@greguintow/nest-fgql

v2.1.0

Published

Fast, lightweight GraphQL module to be used in NestJS

Downloads

2

Readme

nest-fgql

A fast and lightweight module to expose GraphQL APIs in a NestJS application.

Description

This is intended to be a drop-in replacement for @nestjs/graphql that offers improved runtime performance.

Benchmarks show that Apollo adds a noteable overhead regarding performance. Using fastify and graphql-jit via fastify-gql performance is improved.

Usage

Requirements

Must first follow the Performance (Fastify) guide to setup fastify.

Install

yarn add @mirco312312/nest-fgql

Code

import { Module } from '@nestjs/common';
import { FgqlModule } from '@mirco312312/nest-fgql';
// ... your other imports

@Module({
  imports: [
    // ... preceeding modules
    FgqlModule.forRoot({
      autoSchemaFile: true,
      // ... any other options
    }),
    // ... more modules
  ],
})
export class ApplicationModule {}

Performance

Start the test scenario for an environment.

@nestjs/graphql

git clone https://github.com/nestjs/graphql
cd graphql
npm i
npx ts-node tests/code-first/main.ts

nest-fgql

git clone https://github.com/mirco312312/nest-fgql
cd nest-fgql
yarn
npx ts-node tests/code-first/main.ts

Execute autocannon

autocannon -d 10 -c100 \
    -m POST \
    -H 'Content-Type: application/json' \
    -b '{"operationName":null,"variables":{},"query":"{\n  categories {\n    name\n    description\n    tags\n  }\n  recipes {\n    id\n    ingredients {\n      name\n    }\n    rating\n    averageRating\n  }\n}\n"}' \
    http://localhost:3000/graphql

Results

MacBook Pro (16-inch, 2019)

  • 2,4 GHz 8-Core Intel Core i9
  • 64 GB 2667 MHz DDR4

@nestjs/graphql

Running 10s test @ http://localhost:3000/graphql
100 connections

┌─────────┬───────┬───────┬───────┬───────┬──────────┬─────────┬───────────┐
│ Stat    │ 2.5%  │ 50%   │ 97.5% │ 99%   │ Avg      │ Stdev   │ Max       │
├─────────┼───────┼───────┼───────┼───────┼──────────┼─────────┼───────────┤
│ Latency │ 25 ms │ 29 ms │ 61 ms │ 67 ms │ 30.89 ms │ 8.83 ms │ 176.23 ms │
└─────────┴───────┴───────┴───────┴───────┴──────────┴─────────┴───────────┘
┌───────────┬────────┬────────┬─────────┬─────────┬─────────┬────────┬────────┐
│ Stat      │ 1%     │ 2.5%   │ 50%     │ 97.5%   │ Avg     │ Stdev  │ Min    │
├───────────┼────────┼────────┼─────────┼─────────┼─────────┼────────┼────────┤
│ Req/Sec   │ 1613   │ 1613   │ 3429    │ 3579    │ 3183.2  │ 576.32 │ 1613   │
├───────────┼────────┼────────┼─────────┼─────────┼─────────┼────────┼────────┤
│ Bytes/Sec │ 807 kB │ 807 kB │ 1.72 MB │ 1.79 MB │ 1.59 MB │ 288 kB │ 807 kB │
└───────────┴────────┴────────┴─────────┴─────────┴─────────┴────────┴────────┘

Req/Bytes counts sampled once per second.

32k requests in 10.05s, 15.9 MB read

nest-fgql

Running 10s test @ http://localhost:3000/graphql
100 connections

┌─────────┬──────┬──────┬───────┬───────┬─────────┬─────────┬──────────┐
│ Stat    │ 2.5% │ 50%  │ 97.5% │ 99%   │ Avg     │ Stdev   │ Max      │
├─────────┼──────┼──────┼───────┼───────┼─────────┼─────────┼──────────┤
│ Latency │ 7 ms │ 8 ms │ 12 ms │ 13 ms │ 8.94 ms │ 1.52 ms │ 29.08 ms │
└─────────┴──────┴──────┴───────┴───────┴─────────┴─────────┴──────────┘
┌───────────┬─────────┬─────────┬─────────┬────────┬─────────┬─────────┬─────────┐
│ Stat      │ 1%      │ 2.5%    │ 50%     │ 97.5%  │ Avg     │ Stdev   │ Min     │
├───────────┼─────────┼─────────┼─────────┼────────┼─────────┼─────────┼─────────┤
│ Req/Sec   │ 10327   │ 10327   │ 10591   │ 10935  │ 10607.2 │ 164.39  │ 10326   │
├───────────┼─────────┼─────────┼─────────┼────────┼─────────┼─────────┼─────────┤
│ Bytes/Sec │ 4.15 MB │ 4.15 MB │ 4.26 MB │ 4.4 MB │ 4.26 MB │ 66.2 kB │ 4.15 MB │
└───────────┴─────────┴─────────┴─────────┴────────┴─────────┴─────────┴─────────┘

Req/Bytes counts sampled once per second.

106k requests in 10.05s, 42.6 MB read

Credits

Heavily based on @nestjs/graphql.