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

@appliedpiper/graphql-template-contract

v1.0.0

Published

A GraphQL server template built with TypeScript, Apollo Server, and MongoDB.

Readme

GraphQL TypeScript Template

A standalone GraphQL server template built with TypeScript, MongoDB, and Apollo Server, designed for rapid API development. GraphQL Server can be deployed in a local or containerized environment.


Table of Contents

Features

  • TypeScript-first GraphQL API
  • MongoDB as primary data source
  • Modular .graphql schema files
  • Apollo Server context with multiple datasources support
  • Custom Scalars (Date, Email)
  • GraphQL Codegen for TypeScript types
  • Seed data mutations for users and orders
  • Jest tests for resolvers and database operations
  • Containerized GraphQL Production and Development builds

Prerequisites

  • Node.js >= 18
  • pnpm >= 10
  • MongoDB instance (local or cloud)

Getting Started

Follow these steps to set up the project locally:

  1. Install pnpm globally (if not already installed):
npm install -g pnpm
  1. Clone the Repository
git clone https://github.com/appliedpiper/graphql-ts-template.git
cd graphql-ts-template
  1. Install the Dependencies
pnpm install
  1. Configure Environment Variables Update the .env file in the project root to specify the MongoDB URI, Database Name and GraphQL Port
DOTENV_CONFIG_QUIET=true
GQL_PORT=4000
#Replace the MONGO_URI with your MongoDB connection string
MONGO_URI=mongodb://localhost:27017
DB_NAME=gql_template
  1. Start the Development Server
pnpm dev

Your server should now be running at http://localhost:4000/graphql (or the port you specified).

  1. Seeding the Database Use the GraphQL mutation seedDatabase to populate user and orders collections. Defaults: userCount = 5, orderCount = 10.
mutation SeedDatabase($input: SeedInput) {
  seedDatabase(input: $input) {
    ordersInserted
    usersInserted
  }
}

Define the SeedInput as part of the gql variables

  "variables": {
    "input": {
      "orderCount": 10,
      "userCount": 20
    }
  }
  1. Execute GQL Queries From http://localhost:4000/graphql Build a query such as
query USER_QUERY {
  user(name: "1") {
    firstName
    lastName
    email
    orders {
      total
      createdAt
    }
  }
}
  1. Customizing the Schema Update the schema as desired (/src/schema), creating new types, scalars, queries and mutations. After you make changes be sure to stop the GraphQL server and run:
pnpm generate

This will create the new TypeScript Types from the GraphQL Schema in /src/generated/types.ts. /src/schema/typeDefs.ts imports all sub-schemas.

Depending on the size of your project or organizational preference, you may want to organize your schema directory based on feature.

Ex:

src/
├─ schema/
│ ├─ user/
│ │ ├─ typeDefs.graphql
│ │ ├─ resolvers.ts
│ ├─ order/
│ │ ├─ typeDefs.graphql
│ │ ├─ resolvers.ts
  1. Testing JEST is configured for Typescript. Example test cases are located in /src/tests/*.test.ts. Tests and coverage report can be executed by running:
pnpm test
  1. Docker To improve the deployment process I included a Dockerfile and docker-compose.yml to fully containerize a production or development environments.
# Development mode with hot reload
docker-compose up graphql-dev --build

# Production mode
docker-compose up graphql-prod --build

Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/my-feature)
  3. Commit your changes (git commit -m 'Add new feature')
  4. Push to the branch (git push origin feature/my-feature)
  5. Open a pull request

License

This project is licensed under the MIT License - see the LICENSE file for details.