Registry / database / graphql-tools-sequelize

graphql-tools-sequelize

JSON →
library2.3.0jsnpmunverified

Integrates GraphQL-Tools with Sequelize ORM to auto-generate GraphQL schema definitions and resolvers for CRUD operations on entities and their relationships. Version 2.3.0 is the latest stable release, with a low update cadence (last update 2022). Unlike manual schema building, it maps Sequelize models to GraphQL types automatically, including associations and optional full-text search via ElasticLunr. Requires graphql >=0.13, graphql-tools >=3.0, graphql-tools-types >=1.1, and sequelize >=4.0 as peer dependencies. Provides hooks for validation, authorization, and tracing. ESM-only with Node >=8.

npm install graphql-tools-sequelize
INSTALL
IMPORT
SIG · GRAPHQL-TOOLS-SEQU
G
graphql-tools-sequelize
databasejavascriptv2.3.0
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.

GraphQLToolsSequelize
import GraphQLToolsSequelize from 'graphql-tools-sequelize'
const { GraphQLToolsSequelize } = require('graphql-tools-sequelize')
Default export only; named import will fail. CommonJS require works only via default syntax: const GraphQLToolsSequelize = require('graphql-tools-sequelize').default or with esModuleInterop.
GraphQLToolsSequelize class
const gts = new GraphQLToolsSequelize(sequelizeInstance)
new GraphQLToolsSequelize()
Constructor requires a Sequelize instance as the first argument. Omitting it causes runtime error.
entityQuerySchema method
gts.entityQuerySchema('Root', '', 'OrgUnit')
gts.entityQuerySchema('OrgUnit')
Method signature is (typeName, prefix, entityName). Missing arguments results in undefined behavior.

Initializes Sequelize, defines a model, creates GraphQLToolsSequelize instance, boots it, and generates a sample schema definition string.

import Sequelize from 'sequelize'; import GraphQLToolsSequelize from 'graphql-tools-sequelize'; const db = new Sequelize('database', 'username', 'password', { dialect: 'sqlite', storage: ':memory:', logging: false }); const User = db.define('User', { id: { type: Sequelize.UUID, primaryKey: true }, name: { type: Sequelize.STRING }, email: { type: Sequelize.STRING } }); const gts = new GraphQLToolsSequelize(db); await gts.boot(); const typeDefs = ` scalar UUID type Root { ${gts.entityQuerySchema('Root', '', 'User')} ${gts.entityQuerySchema('Root', '', 'User*')} } schema { query: Root } `; console.log(typeDefs);
Debug
Known issues
breakingVersion 2.0 changed the API from synchronous factory functions to an async class with boot() method. Old code using synchronous initialisation will break.
fix
Upgrade to v2 and instantiate with `new GraphQLToolsSequelize(db)` then `await gts.boot()`.
affects: <2.0.0
deprecatedThe library is in maintenance mode; no active development since 2022. Future compatibility with newer Sequelize (>=6) or GraphQL (>=16) is not guaranteed.
fix
Consider alternatives like graphql-sequelize or manual schema building for long-term projects.
affects: >=2.0.0
gotchaConstructor expects a Sequelize instance, but passing an empty instance without models defined will cause boot() to succeed but generate empty schemas.
fix
Define all Sequelize models before creating GraphQLToolsSequelize instance and calling boot().
affects: >=2.0.0
gotchaThe library uses ES modules (ESM). Requiring with CommonJS require will return the default export as { default: ... } unless esModuleInterop is enabled.
fix
Use import syntax or enable esModuleInterop in tsconfig.json / use babel for CJS compatibility.
affects: >=2.0.0
Errors
Common errors & fixes
TypeError: GraphQLToolsSequelize is not a constructor
Importing using named import instead of default import, or using require without .default.
fix
Use `import GraphQLToolsSequelize from 'graphql-tools-sequelize'` or `const GraphQLToolsSequelize = require('graphql-tools-sequelize').default`.
Cannot read property 'entityQuerySchema' of undefined
gts.boot() not awaited before calling schema generation methods.
fix
Ensure `await gts.boot()` executes before accessing gts methods.
Must provide a valid Sequelize instance
Constructor called without arguments or with non-Sequelize object.
fix
Pass a valid Sequelize instance to the constructor: `new GraphQLToolsSequelize(sequelizeInstance)`.
Upgrade
Version history
2.3.0latest on npm
Audit
Dependencies
graphqlrequiredPeer dependency — core GraphQL runtime for schema execution and type system.
graphql-toolsrequiredPeer dependency — provides makeExecutableSchema and schema stitching utilities.
graphql-tools-typesrequiredPeer dependency — provides additional GraphQL scalar types like UUID and JSON.
sequelizerequiredPeer dependency — ORM for defining models and querying the database.
Agent activity
4 hits · last 30 days
node
4
Resources
graphql-tools-sequelize — npm install graphql-tools-sequelize · libregistry