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

apolloems

v1.0.0

Published

An easy way to modularize the scheme

Readme

Easy Modularization Scheme for Apollo-Server (Graphql)

This package allows you to do in an easy way the schema modularization for your server.

Prerequisites

You need an apollo-server installation in your server and you need to put all your types in /schema/types and resolvers in /schema/resolvers

Installing

It's simple. With npm:

npm install --save apolloems

How to use

This package reads two folders. '/schema/resolvers/' and '/schema/types/'. So, you can generate automatically a Schema.

You can see the '/example' folder for more help. But it's easy to understand.

  1. Install this package
  2. In your server.js (or equivalent) require easy-modularization-scheme and call the functon ems to generate the schema
const { graphqlExpress, graphiqlExpress } = require('apollo-server-express') ;
const { makeExecutableSchema } = require('graphql-tools');
const ems = require('easy-modularization-scheme')

const schema = makeExecutableSchema(ems());

const GRAPHQL_PORT = 3000;

const graphQLServer = express();

graphQLServer.use('/graphql', bodyParser.json(), graphqlExpress({ schema }));
  1. You need to put all types in this way:

/schema/types/Author.js

const Post = `
type Post {
  id: Int!
  title: String
  author: Author
  votes: Int
}
`

const RootQuery = `
  posts: [Post]
`

const Mutation = `
  upvotePost (
    postId: Int!
  ): Post
`

const Type = () => [Post]
module.exports = {
  Type,
  RootQuery,
  Mutation
}

The most important part is this.

...
const Type = () => [Post]
module.exports = {
  Type,
  RootQuery,
  Mutation
}

You need to put in Type function ALL the types in the file. You can include several types. But for recommendation, one variable per type (If you want to declare a Type called Books for example, i suggest use const Book = type Book ...)

If you don't declare a RootQuery or Mutation you can avoid their declaration.

  1. With the resolvers. You need to add in this way:
const { find, filter } = require('lodash');
// example data
const posts = [
  { id: 1, authorId: 1, title: 'Introduction to GraphQL', votes: 2 },
  { id: 2, authorId: 2, title: 'Welcome to Meteor', votes: 3 },
  { id: 3, authorId: 2, title: 'Advanced GraphQL', votes: 1 },
  { id: 4, authorId: 3, title: 'Launchpad is Cool', votes: 7 },
];

module.exports = {
  RootQuery: {
    posts: () => posts
  },
  Mutation: {
    upvotePost: (_, { postId }) => {
      const post = find(posts, { id: postId });
      if (!post) {
        throw new Error(`Couldn't find post with id ${postId}`);
      }
      post.votes += 1;
      return post;
    },
  },
  Author: {
    posts: (author) => filter(posts, { authorId: author.id }),
  }
};

Use always RootQuery instead of Query.

  1. Done! Run your server!

Tests

Sorry. No test yet.

History

V1.0.0 First version

Todo

  • [ ] Allow custom scalars
  • [ ] Subscriptions
  • [ ] Allow Comments in RootQuery and mutation

License

This project is licensed under the MIT License

Acknowledgments

  • Apollo GraphQL staff
  • My FullStack devs Facebook Group
  • React Community