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

user-graphql-server-mocked

v1.6.0

Published

GraphQL server with mocked data using Yoga

Downloads

124

Readme

User Management GraphQL Server (Mocked)

A fully functional GraphQL server with mocked data built using GraphQL Yoga and TypeScript. This server implements a comprehensive user management schema with authentication, profiles, and various social login methods.

Features

  • Full GraphQL schema implementation based on introspection schema
  • All resolvers return realistic mocked data
  • Support for Queries, Mutations, and Subscriptions
  • GraphiQL interface for testing
  • TypeScript for type safety
  • Hot reload during development

Schema Overview

The server implements a comprehensive user management system with:

  • User authentication (password, OAuth, Web3 wallets, Telegram)
  • Profile management
  • 2FA (OTP and SMS)
  • Email verification
  • Password reset
  • Social profiles (Steam, Facebook, Twitter)
  • Country and localization support
  • Device management
  • Session management

Getting Started

Prerequisites

  • Node.js (v18 or higher)
  • pnpm (or npm/yarn)

Installation

pnpm install

Development

Start the development server with hot reload:

pnpm run dev

The server will start at http://localhost:5000/graphql

Create admin users

npm run cli create-admin -- -e <email> -p <password> -n <name>

Change admin password

npm run cli change-admin-password -- -e <email> -p <new_password>

Build

Compile TypeScript to JavaScript:

pnpm run build

Production

Run the compiled server:

pnpm start

Usage

GraphiQL Interface

Visit http://localhost:5000/graphql in your browser to access the enhanced interactive GraphiQL interface where you can:

  • Explore the schema - Browse all available types, queries, mutations, and subscriptions
  • Test queries and mutations - Execute operations with syntax highlighting and auto-completion
  • View documentation - Built-in documentation explorer for all GraphQL types and fields
  • Run subscriptions - Test real-time subscription operations
  • Pre-loaded examples - Ready-to-run example queries and mutations on page load
  • Modern UI - Clean, responsive interface with custom styling

The GraphiQL interface comes pre-loaded with example queries including:

  • Get current user and profile information
  • Authentication configuration
  • Login with password
  • User registration

Example Queries

Get Current User

query {
  userManagement {
    id
    currentUser {
      id
      username
      email
      hasWeakPassword
      authMethods
    }
    currentProfile {
      id
      firstName
      lastName
      email
      emailVerified
      country
      phone
      isKycVerified
    }
  }
}

Login with Password

mutation {
  userManagementLoginViaPassword(
    input: {
      site: "main"
      username: "testuser"
      password: "password123"
    }
  ) {
    token
    labToken
    sessionId
    userType {
      id
      username
      email
    }
    profileType {
      id
      firstName
      lastName
      email
    }
    errors {
      message
      code
    }
  }
}

Register New User

mutation {
  userManagementRegisterAsUser(
    input: {
      site: "main"
      username: "newuser"
      email: "[email protected]"
      password: "securepass123"
      firstName: "John"
      lastName: "Doe"
      dateOfBirth: 946684800
      country: "US"
      language: "en"
    }
  ) {
    token
    sessionId
    userType {
      id
      username
      email
    }
    profileType {
      id
      firstName
      lastName
      email
      country
    }
    errors {
      message
      code
    }
  }
}

Update Profile

mutation {
  userManagementUpdateProfile(
    input: {
      firstName: "Jane"
      lastName: "Smith"
      phone: "+15551234567"
      city: "New York"
      language: "en"
    }
  ) {
    profileType {
      id
      firstName
      lastName
      phone
      city
    }
    errors {
      message
    }
  }
}

Example Subscriptions

subscription {
  userManagementWaitForLoginToken(
    input: { loginSessionId: "session_123" }
  ) {
    token
    errors {
      message
    }
  }
}

Project Structure

.
├── src/
│   ├── index.ts        # Server entry point
│   ├── resolvers.ts    # GraphQL resolvers with mocked data
│   ├── mocks.ts        # Mock data generators
│   └── types.ts        # TypeScript type definitions
├── scripts/
│   └── introspection-to-sdl.js  # Schema conversion utility
├── schema.json         # Original introspection schema
├── schema.graphql      # Generated SDL schema
├── package.json
├── tsconfig.json
└── README.md

Mock Data

All resolvers return realistic mocked data including:

  • Randomized user information
  • Valid email addresses and usernames
  • JWT tokens and session IDs
  • Country and localization data
  • Social profile information
  • Error responses (empty arrays by default)

The mock data generators are located in src/mocks.ts and can be customized as needed.

Environment Variables

  • PORT - Server port (default: 5000)

Example:

PORT=5000 pnpm run dev

Schema Conversion

If you need to regenerate the SDL schema from the introspection result:

pnpm run generate-schema

This will read schema.json and output schema.graphql.

Development Notes

  • The server uses GraphQL Yoga for optimal performance and developer experience
  • All mutations return success responses with mocked data
  • Subscriptions simulate async operations with 2-second delays
  • The Node interface is properly implemented for relay-style pagination support

License

ISC