Registry / devops / graphql-modules

graphql-modules

JSON →
library3.1.2jsnpmunverified

GraphQL Modules is a toolset for building modular, reusable, and maintainable GraphQL servers. It enforces a schema-first design, allowing you to split your GraphQL schema into multiple modules that can be developed, tested, and scaled independently. Current stable version is 3.1.2, with frequent updates and a canary release channel. It provides features like dependency injection, application context, and testing utilities. It is actively maintained by The Guild and supports GraphQL v14-16. Key differentiators: first-class TypeScript support, dependency injection built-in, and a clear migration path from simple to complex architectures.

npm install graphql-modules
INSTALL
IMPORT
SIG · GRAPHQL-MODULES
G
graphql-modules
devopsjavascriptv3.1.2
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

createModule
import { createModule } from 'graphql-modules'
import createModule from 'graphql-modules'
createModule is a named export, not default
createApplication
import { createApplication } from 'graphql-modules'
const { createApplication } = require('graphql-modules')
Package is ESM-only since v3; require() will fail
gql
import { gql } from 'graphql-modules'
import { gql } from 'graphql'
graphql-modules re-exports gql tag from graphql-tag
Inject
import { Inject } from 'graphql-modules'
import { inject } from 'graphql-modules'
Capitalized `Inject` for dependency injection decorator
GraphQLModule
import { GraphQLModule } from 'graphql-modules'
import { Module } from 'graphql-modules'
Class name for module configuration object

Shows basic usage of createModule and createApplication to build a modular GraphQL server.

import { createModule, createApplication, gql } from 'graphql-modules'; const userModule = createModule({ id: 'user', typeDefs: gql` type User { id: ID name: String } type Query { users: [User] } `, resolvers: { Query: { users: () => [{ id: '1', name: 'Alice' }], }, }, }); const app = createApplication({ modules: [userModule], }); app.createExecutionFn(); // returns executable schema
Debug
Known issues
breakingVersion 3.x requires ESM usage. CommonJS require() will not work.
fix
Use import syntax or set type:'module' in package.json.
affects: >=3.0.0
breakingDropped support for GraphQL v13 in v3. Minimum GraphQL version is 14.
fix
Upgrade graphql dependency to v14, v15, or v16.
affects: >=3.0.0
deprecatedGraphQLModule import deprecated in favor of createModule function in v3.
fix
Use createModule() instead of new GraphQLModule().
affects: >=3.0.0
gotchaDependency injection requires reflect-metadata polyfill at top of entry file.
fix
Add import 'reflect-metadata' at the start of your application entry point.
affects: >=2.0.0
gotchaWhen using resolvers composition with `use`, the order of middleware matters and can cause unexpected behavior if not careful.
fix
Ensure middleware order follows execution pipeline (e.g., auth before data fetching).
affects: >=1.0.0
Errors
Common errors & fixes
Cannot find module 'graphql-modules'
Package not installed or typo in package name.
fix
Run 'npm install graphql-modules' or check package.json.
require() of ES Module not supported
Using CommonJS require() to import graphql-modules, which is ESM-only.
fix
Use import syntax or set type:'module' in package.json.
Reflect has no metadata
Missing reflect-metadata polyfill for dependency injection.
fix
Add 'import "reflect-metadata"' at the top of your entry file.
Cannot use import statement outside a module
Node.js not configured to support ES modules.
fix
Add "type": "module" to package.json or use .mjs extension.
Upgrade
Version history
3.1.2latest on npm
Audit
Dependencies
graphqlrequiredPeer dependency required for GraphQL schema processing and execution
Agent activity
6 hits · last 30 days
node
6
Resources
graphql-modules — npm install graphql-modules · libregistry