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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@basementscripts/graphql-schema-builder

v1.1.6

Published

GraphQL Schema Builder for Node.js

Downloads

22

Readme

@basementscripts/graphql-schema-builder

Implement Schema in ApolloServer instance

import { ApolloServer, ApolloServerExpressConfig } from 'apollo-server-express'
import { SchemaBuilder } from '@basementscripts/graphql-schema-builder'
import { base, input, filter } from '@basementscripts/graphql-schema-builder/typeDefs'
import { UserTypeDefs, UserResolver } from '@user-service/graphql'

const builder = new SchemaBuilder({
	typeDefs: [base, input, filter, UserTypeDefs],
	resolvers: [UserResolver]
})

const server = new ApolloServer({
	schema: builder.toSchema()
	//...config
})

Resolver

import {
	field,
	fields,
	mutation,
	query,
	resolver
} from '@basementscripts/graphql-schema-builder/decorators'

@resolver()
export default class AuthRoleResolver extends Resolver {
	@fields('account')
	User

	@query()
	getUser(root, input): GraphQLResponse<any> {
		return input
	}

	@mutation()
	createUser(root, { input }: any): GraphQLResponse<any> {
		return input
	}

	@field('user')
	sideEffectUser({ user }) {
		return user
	}

	@field('users')
	sideEffectUsers({ users }) {
		return users
	}
}

Plugins

import { ApolloServer } from '@apollo/server'
import { ApolloServerPluginDrainHttpServer } from '@apollo/server/plugin/drainHttpServer'
import { expressMiddleware } from '@as-integrations/express5'
import express from 'express'
import http from 'http'
import cors from 'cors'
import { typeDefs, resolvers } from './schema'

interface MyContext {
	token?: String
}

const app = express()
// Our httpServer handles incoming requests to our Express app.
// Below, we tell Apollo Server to "drain" this httpServer,
// enabling our servers to shut down gracefully.
const httpServer = http.createServer(app)

const server = new ApolloServer<MyContext>({
	typeDefs,
	resolvers,
	plugins: [ApolloServerPluginDrainHttpServer({ httpServer })]
})
await server.start()

app.use(
	'/graphql',
	cors<cors.CorsRequest>(),
	express.json(),
	expressMiddleware(server, {
		context: async ({ req }) => ({ token: req.headers.token })
	})
)

await new Promise<void>((resolve) => httpServer.listen({ port: 4000 }, resolve))

console.log(`🚀 Server ready at http://localhost:4000/graphql`)

Cache Control

import { ApolloServer } from '@apollo/server'
import { ApolloServerPluginCacheControl } from '@apollo/server/plugin/cacheControl'

const server = new ApolloServer({
	typeDefs,
	resolvers,
	plugins: [
		ApolloServerPluginCacheControl({
			// Cache everything for 1 second by default.
			defaultMaxAge: 1,
			// Don't send the `cache-control` response header.
			calculateHttpHeaders: false
		})
	]
})

Disable Cache

import { ApolloServer } from '@apollo/server'
import { ApolloServerPluginCacheControlDisabled } from '@apollo/server/plugin/disabled'

const server = new ApolloServer({
	typeDefs,
	resolvers,
	plugins: [ApolloServerPluginCacheControlDisabled()]
})

Development

Changelog

This project uses an automated changelog system with Git hooks. The CHANGELOG.md file is automatically updated on each commit based on the commit message.

Commit Message Format

The changelog system automatically categorizes changes based on keywords in your commit messages:

  • Added: feat, add, new
  • Fixed: fix, bug
  • Changed: change, update, modify
  • Removed: remove, delete
  • Deprecated: deprecate
  • Security: security

Git Hooks

The project includes a commit-msg hook that automatically:

  1. Reads your commit message
  2. Categorizes the change based on keywords
  3. Updates the CHANGELOG.md file in the [Unreleased] section
  4. Adds the updated changelog to your commit

Manual Changelog Updates

If you need to manually update the changelog, edit CHANGELOG.md directly. The file follows the Keep a Changelog format.

Version Releases

When releasing a new version:

  1. Update the version in package.json
  2. Move entries from [Unreleased] to a new version section (e.g., [1.1.0] - 2024-01-15)
  3. Add the release date
  4. Commit the changes