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-modules-fn

v0.1.0-alpha9

Published

GraphQL modules with a functional influence.

Readme

GraphQL Modules (fn)

npm version bundlephobia Downloads/week License build status coverage

UNDER HEAVY DEVELOPMENT

Motivation

Apollo's GraphQL server supports modules which uses plain GraphQL's schema language allowing developers to separate type definitions and resolvers by domains. This feature should it be separated from Apollo's server so we can use this concept with other server enabling this feature on the browser with somehting like apollo-link-schema.

The (fn) on the name is because it has a more "functional" style than the graphql-modules.

GraphQL Modules is a very nice battle tested, well documented and complete set of tools. But for some cases it can be an overhead for a team which just wants to organize their code in modules, no dependency injection or injectable providers. It has a strong opinion of how to use DI, how to handle context or resolvers composition. Also it has a more object (class) oriented programming which can be overwelming for some developers which prefer the functional style. Not a good option to use GraphQL on the browser since the @graphql-modules/[email protected] is 55.7 kB minified + gzipped without the rest of the suite of tools like @graphql-modules/[email protected] which needs the Reflect Metada api that doesn't exist in the browser yet.

Usage

Installation

npm i graphql-modules-fn

or

yarn add graphql-modules-fn

Example of a simple blog.

import gql from 'graphql-tag'

const typeDefs = gql`
  type User {
    id: ID!
    name: String!
  }

  extend type Query {
    users: [User]!
  }
`

const resolvers = {
  Query: {
    users: (root, args, context) => [
      { id: '1', name: 'Sebas' },
      { id: '2', name: 'Rick' },
      { id: '3', name: 'Morty' },
    ],
  },
}

export default { typeDefs, resolvers }
import gql from 'graphql-tag'

const typeDefs = gql`
  type Comment {
    id: ID!
    title: String!
    body: String!
    author: User!
  }

  extend type Content {
    comments: [Comment]!
  }
`

const resolvers = {
  Content: {
    comments: (root, args, context) => [
      {
        id: '1',
        title: 'Proident senectus',
        body: 'Cras varius proident senectus!',
        author: { id: '1', name: 'Sebas' },
      },
      {
        id: '2',
        title: 'Faucibus feugiat pulvinar quam',
        body: 'Consectetur soluta, incidunt semper.',
        author: { id: '2', name: 'Rick' },
      },
    ],
  },
}

export default { typeDefs, resolvers }
import gql from 'graphql-tag'

const typeDefs = gql`
  type Content {
    id: ID!
    title: String!
    body: String
  }

  extend type User {
    articles: [Content]!
  }
`

const resolvers = {
  User: {
    articles: (root, args, context) => [
      {
        id: '1',
        title: 'Sapiente quidem architecto',
        body:
          'Augue tempora excepteur, cras varius proident senectus minima fuga proident temporibus fuga!',
      },
      {
        id: '2',
        title: 'Fuga curae illum suscipit eget',
        body:
          'Faucibus feugiat pulvinar quam, consectetur soluta, incidunt semper! Nobis ipsum, aliquid excepteur.',
      },
    ],
  },
}

export default { typeDefs, resolvers }
import { bundle } from 'graphql-modules-fn'

import content from './modules/content'
import user from './modules/user'
import comment from './modules/comment'

const modules = [user, comment, content]

export default function createSchema() {
  return bundle(modules) //=> { schema, context }
}
import { ApolloServer } from 'apollo-server'

import createSchema from './createSchema'

export default async function createServer(port) {
  const { schema, context } = await createSchema()

  return new ApolloServer({ schema, context }).listen(port)
}
import createServer from './createServer'

const { PORT = 3000 } = process.env

const server = createServer(PORT).then(({ url }) => {
  console.log(`🚀 Server eready at ${url}`)
})

More examples:

Running GraphQL in the browser

Base modules

  • 10.3kb | @apollographql/apollo-tools
  • 40.9kb | graphql
  • 3.7kb | apollo-link-schema
  • 984b | graphql-tag
  • 2.5kb | react-apollo-hooks
  • 16kb | apollo-client
  • 9.7kb | apollo-cache-inmemory

Bundle size: ~84kb.

GraphQL Modules (fn)

  • 1.1kb | graphql-modules-fn

Bundle size: ~85kb.

  • 55.2kb | @graphql-modules/core

Bundle size: ~139kb. Incrementing ~40% of your bundle size.

TODO:

  • [ ] Add usage of contexts.
  • [ ] Start a documentation site.
  • [ ] Subscriptions support (waiting for PR #1047 to be merged).
  • [ ] Tests with 100% of converage.