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

@schematizer/schematizer

v1.0.1

Published

This is another library for make graphql schemas with hard type declaration on arguments, types and inputs

Readme

Schematizer

This is another library for make graphql schemas with hard type declaration on arguments, types and inputs

Installation

you can install it with yarn or npm

yarn add @schematizer/schematizer

or

npm install @schematizer/schematizer

docs

Example

You can see the quick start demo or see the next code examplte to show how this library works

import { Fn, Queries, schematize, Type }  from '@schematizer/schematizer';
import { graphql } from 'graphql';

// make a type

class Product {
  public id: number;
  public name: string;
  public price: number;
  public salable: boolean;
}

const productType = new Type(Product).fields(() => ({
  id: 'int',
  name: 'string',
  price: 'float',
  salable: 'boolean',
}));

const products: Product[] = [
  { id: 1, name: 'foo', price: 5, salable: true },
  { id: 2, name: 'bar', price: 2, salable: true },
];

// make queries

const queries = new Queries({
  products: Fn([Product], () => () => products),
});

// schematize

const schema = schematize(productType, queries);
const source = `
  query {
    products {
      id
      name
      price
      salable
    }
  }
`;

// you can use your favorite server like "graphql yoga" or "apollo server"
const { data, errors } = await graphql({ schema, source });

Type

The Type class defines a graphql type, first we need define a class that will represent our type and we will create a Type instance

import { Type } from '@schematizer/schematizer';

class Person {
  public id: number;
  public name: string;
}

const personType = new Type(Person)
  .as('userType') // optional
  .fields(() => ({
    id: 'int',
    name: 'string',
  }));

Input

Similar to Type, we need define a class to represent an input

import { Input } from '@schematizer/schematizer';

class MovementInput {
  public from: number;
  public to: number;
  public amount: number;
  public description: string;
}

const movementInput = new Input(MovementInput).fields(() => ({
  from: 'int',
  to: 'int',
  amount: 'float',
  description: 'string',
}));

Query

To define graphql queries we need use Queries class, we will define the queries in the constructor argument

import { Arg, Fn, Queries } from '@schematizer/schematizer';
import { Product } from '../types';
import { getProductsMagically, getProductMagically } from '../magic';

const queries = new Queries({
  getProducts: Fn([Product], ({
    sqlInject = Arg('string'), // do not do this
  }) => () => {
    return getProductsMagically(sqlInject);
  }),

  getProduct: Fn(Product, ({
    id = Arg('int'),
  }) => () => {
    return getProductMagically(id);
  }),
});

Mutation

The mutations works just like queries, but with the Mutations class

import { Arg, Fn, Mutations } from '@schematizer/schematizer';
import { Product } from '../types';
import { ProductInput } from '../inputs';
import { addProductMagically, removeProductMagically } from '../magic';

const mutations = new Mutations({
  addProduct: Fn(Product, ({
    input = Arg(ProductInput),
  }) => () => {
    return addProductMagically(input);
  }),

  removeProduct: Fn(Product, ({
    id = Arg('int'),
  }) => () => {
    return removeProductMagically(id);
  }),
});