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

nest-ql-schema

v0.0.5

Published

GraphQL schema definitions and generated types for Nest Tanzania Rental Platform

Readme

Nest GraphQL Schema Package

GraphQL schema definitions and generated TypeScript types for Tanzania Nest Rental Platform.

Installation

npm install nest-ql-schema

Usage

1. In CDK (AppSync API)

import * as appsync from 'aws-cdk-lib/aws-appsync';
import { schemaPath, SCHEMA_VERSION } from 'nest-ql-schema';

// Create AppSync API with schema
const api = new appsync.GraphqlApi(this, 'NestAPI', {
  name: 'nest-rental-api',
  schema: appsync.SchemaFile.fromAsset(schemaPath),
  authorizationConfig: {
    defaultAuthorization: {
      authorizationType: appsync.AuthorizationType.API_KEY,
    },
    additionalAuthorizationModes: [
      {
        authorizationType: appsync.AuthorizationType.USER_POOL,
        userPoolConfig: { userPool }
      }
    ]
  }
});

console.log(`Schema version: ${SCHEMA_VERSION}`);

2. Type-Safe Resolvers

import type { 
  QueryResolvers, 
  MutationResolvers,
  Property,
  PropertyCard,
  Application
} from 'nest-ql-schema';

// Implement type-safe resolvers
const queryResolvers: QueryResolvers = {
  getProperty: async (_, { propertyId }, context) => {
    const property = await dynamoDB.get({
      TableName: 'Properties',
      Key: { propertyId }
    });
    return property.Item as Property;
  },
  
  getPublicInitialData: async (_, { limit, nextToken }) => {
    const regions = await getRegions();
    const properties = await getRecentProperties(limit, nextToken);
    const featured = await getFeaturedProperties();
    
    return {
      regions,
      recentProperties: properties,
      featuredProperties: featured
    };
  }
};

const mutationResolvers: MutationResolvers = {
  addToFavorites: async (_, { propertyId }, context) => {
    const userId = context.identity.sub;
    await dynamoDB.put({
      TableName: 'UserActivity',
      Item: {
        PK: `USER#${userId}`,
        SK: `FAVORITE#${propertyId}`,
        propertyId,
        favoritedAt: new Date().toISOString()
      }
    });
    return { success: true, message: 'Property added to favorites' };
  }
};

3. Using Types in Lambda Functions

import type { Property, PropertyInput } from 'nest-ql-schema';

export const handler = async (event: any) => {
  const property: Property = {
    propertyId: 'prop-123',
    landlordId: 'user-456',
    title: 'Beautiful Apartment',
    description: '2 bedroom apartment in Ilala',
    // ... fully typed
  };
  
  return property;
};

4. Runtime Schema Validation

import { schema } from 'nest-ql-schema';
import { buildSchema } from 'graphql';

// Use schema string for runtime validation
const executableSchema = buildSchema(schema);

Package Structure

After publishing to npm, the package contains:

nest-ql-schema/
├── dist/
│   ├── src/
│   │   ├── index.js         # Main export
│   │   └── index.d.ts       # TypeScript definitions
│   ├── schemas/
│   │   ├── schema.graphql   # Complete unified schema
│   │   ├── location.graphql # Location hierarchy
│   │   └── application.graphql # Application workflow
│   └── generated/
│       ├── types.ts         # Generated TypeScript types
│       ├── resolvers.ts     # Resolver type definitions
│       └── introspection.json
└── package.json

Exports

// Types
export * from './generated/types';
export type { Resolvers, QueryResolvers, MutationResolvers, SubscriptionResolvers };

// Schema
export const schema: string;           // Schema as string
export const schemaPath: string;        // Path to schema file (for CDK)
export const SCHEMA_VERSION: string;    // Version number

// Introspection
export function getIntrospection(): any;  // Lazy-loaded introspection data

Build & Publish

# Build the package
npm run build

# Publish to npm
npm publish

# Or publish with specific tag
npm publish --tag beta

Development

# Install dependencies
npm install

# Generate types from schema
npm run codegen

# Build
npm run build

# Watch mode
npm run watch

GraphQL Schema Features

Complete API

  • 25 Queries (8 public, 17 authenticated)
  • 12 Mutations (consolidated for efficiency)
  • 4 Subscriptions (real-time updates)

Key Types

  • Users: Tenant, Landlord, Admin
  • Properties: Property, PropertyCard (lightweight)
  • Applications: Application, ApplicationCard
  • Locations: Region, District, Ward, Street

Guest Access (No Auth)

  • Browse properties
  • Filter by location, price, amenities
  • View property details
  • See landlord contact

Authenticated Features

  • Personalized dashboard
  • Favorites & recently viewed
  • Application management
  • Landlord/tenant stats

License

MIT

Author

Nest Platform Team