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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@wuyuchentr/mock-graphql-server

v1.0.0

Published

Start a mock GraphQL server from SDL. Auto-generates data, supports pagination, latency, errors. Zero dependencies.

Readme

@wuyuchentr/mock-graphql-server

Start a mock GraphQL server from SDL. Auto-generates data, supports pagination, filtering, sorting, latency, and error simulation. Zero dependencies.

Perfect for frontend development and testing without a real backend.

Install

npm install -g @wuyuchentr/mock-graphql-server

Usage

CLI

# Start from a .graphql file
npx mock-graphql-server schema.graphql --port=4000

# With simulated latency
npx mock-graphql-server schema.graphql --latency=200

# With simulated errors (10%)
npx mock-graphql-server schema.graphql --error-rate=0.1

API

const { mockServer } = require('@wuyuchentr/mock-graphql-server');

// From SDL string
const server = mockServer(`
  type User {
    id: ID!
    name: String!
    email: String!
    age: Int
    posts: [Post!]!
  }
  type Post {
    id: ID!
    title: String!
    content: String!
  }
  type Query {
    users(page: Int, limit: Int, sort: String, filter: String): [User!]!
    user(id: ID!): User
  }
`, {
  latency: 100,          // ms delay per request
  errorRate: 0.05,       // 5% chance of error
  resolvers: {
    Query: {
      user: (args) => ({ id: args.id, name: 'Resolved User' }),
    },
  },
  mocks: {
    User: () => ({ name: 'Custom Mock User' }),
  },
});

server.listen(4000, () => {
  console.log('→ http://localhost:4000/graphql');
});

Smart Mocking

Pagination

Queries with page and limit arguments get paginated results from a pool of 50 items.

query {
  users(page: 1, limit: 10) { id name email }
}

Sorting

query {
  users(sort: "name", order: "desc") { id name }
}

Filtering

query {
  users(filter: "{\"status\": \"active\"}") { id name }
  posts(filter: "{\"title\": {\"contains\": \"lorem\"}}") { id title }
}

Supported operators: eq, ne, gt, gte, lt, lte, contains, in

Custom resolvers

resolvers: {
  Query: {
    user: (args) => ({ id: args.id, name: 'Bob' }),
    users: (args) => [{ id: 1, name: 'Bob' }, { id: 2, name: 'Alice' }],
  },
}

How it works

  1. Parses the SDL to extract type definitions
  2. Generates a pool of mock data per query using field-name-aware heuristics
  3. Runs a lightweight HTTP server (Node.js http module)
  4. Responds to POST /graphql requests
  5. Applies pagination, filtering, sorting from query arguments
  6. Injects configurable latency / error rate