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

graphql-schema-transformer

v0.3.0

Published

Transform pregenerated graphql-schemas

Readme

Prisma-schema-transformer

Unofficial schema-tranformer used to transform autogenerated graphql-schemas.

This library first parser a schema, then lets you use filter, attach and transform to any fields or node matching either strict matches, or more loosely to any regex.

This makes this library very flexible.

Usage

import filterSchema, { IFilter } from 'graphql-schema-transformer'
import { filterGen, typeDescriptions } from 'graphql-schema-transformer/dist/filterGen'

type Pick = Pick<T, Exclude<keyof T, K>>

// General filters
const inputFilters: Array<Omit<IFilter, 'type'>> = [
  {
    // Remove all input where the fields are `createdBy` or `delete` in ANY input
    fieldName: ['createdBy', 'delete'],
  },
  {

    name: /^UserCreateInput/,
    // Remove any fields NOt (invert) listed here:
    fieldName: /firstName|active|lastName|userName|email|altId|altInfo|authPermissions/,
    invert: true,
    // Add these lines:
    add: '  authPermissions: [AuthPermissions!]!\n  password: String!',
  },
  {
    name: /PermissionUpdateManyWithout\w*Input/,
    line: /connect|disconnect/,
    exceptName: 'PermissionUpdateManyWithoutObjectDetailInput',
    invert: true,
  },

]

// filterGen is a helper for creating filters with less code
const includeOnlyLinesMatching = filterGen({
  CollectionUpdateOneWithoutAlbumInput: /connect|disconnect/,
  ObjectDetailUpdateManyWithoutAlbumInput: /connect|create|disconnect/,
  AlbumCreateManyWithoutCollectionInput: /connect/,
  MetaDataFieldCreateOneInput: /connect/,
  ObjectCreateOneInput: /connect/,
  PermissionUpdateManyWithoutObjectDetailInput: /update[^M]/,
  ObjectDetailCreateOneInput: /connect/,
  TagCreateManyInput: /connect/,
  CollectionCreateOneWithoutAlbumsInput: /connect/,
  UserGroupUpdateInput: /name|description/,
  UserGroupUpdateOneInput: /connect|disconnect/,
  ObjectUpdateOneInput: /connect|disconnect/,
  UserCreateOneInput: /connect/,
  FormCreateManyInput: /connect/,
  ObjectDetailCreateManyWithoutTagsInput: /connect/,
  // TagUpdateManyInput: /create|connect|disconnect/,
}, { invert: true })

const excludeLinesMatching = filterGen({
  PermissionCreateInput: /objectDetail|collections|albums/,
  PermissionUpdateInput: /objectDetail|collections|albums/,
  CollectionCreateWithoutAlbumsInput: /groups|users|permissions/,
  AlbumCreateInput: /collection/,
  TagCreateInput: /forms/,
  TagUpdateInput: /forms/,
  PermissionUpdateWithoutObjectDetailDataInput: /user|collections|albums/,
  ObjectDetailUpdateInput: /object|metadata|original|album|actions/,
  AlbumCreateWithoutObjectDetailsInput: /collection/,
  CollectionCreateInput: /group/,
  UserGroupCreateInput: /subGroups|parentGroup/,
})

// typeDescriptions are a custom filter-creator used for adding descriptions
const descriptions = typeDescriptions({
  type: {
    User: {
      id: 'Id of user, (see authId)',
      authId: 'Id used by auth.',
      firstName: 'First name of user',
      active: 'Controls whether a user is able to interact or not with papi',
      lastName: 'Family name of user',
      userName: 'Preferred username',
      email: 'Email of user',
      altId: 'An alternative user-id, in an external database.',
      altInfo: 'Any external info about the user',
    },
  },
  input: {
    UserCreateInput: {
      altId: 'Set to your external id',
    },
  },
})

const fieldFilters = [
  ...inputFilters.map((s) => ({ type: 'input' as any, ...s })),
  ...includeOnlyLinesMatching,
  ...excludeLinesMatching,
  ...descriptions,
]

filterSchema(
  './src/schemas/generated/prisma.graphql', // input
  './src/schemas/generated/preApp.graphql', // output
  fieldFilters)