Registry / database / jonmagic-graphql-sequelize

jonmagic-graphql-sequelize

JSON →
library9.3.4-hack05jsnpmunverified

GraphQL & Relay resolver helper for Sequelize models (MySQL/PostgreSQL). Current stable version is 9.3.4-hack05, with irregular release cadence (pre-v9 was common). Differentiators: automatic args-to-where conversion, built-in Relay connection support, and before/after hooks. Crucial to pair with dataloader-sequelize to avoid N+1 queries. Deprecated in favor of modern patterns; final release likely.

npm install jonmagic-graphql-sequelize
INSTALL
IMPORT
SIG · JONMAGIC-GRAPHQL-S
J
jonmagic-graphql-sequelize
databasejavascriptv9.3.4-hack05
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.

resolver
import { resolver } from 'graphql-sequelize'
const resolver = require('graphql-sequelize').resolver
Default export is a function, but named import is preferred for tree-shaking. ESM works fine.
relayResolver
import { relayResolver } from 'graphql-sequelize'
import { resolver } from 'graphql-sequelize'
Must use relayResolver for Relay connections, not the generic resolver.
default
import gqlSeq from 'graphql-sequelize'
const gqlSeq = require('graphql-sequelize')
Both import and require work; default export is not documented but exists.

Sets up a basic GraphQL endpoint with Sequelize model. Uses resolver to auto-map args to where clause.

import { resolver } from 'graphql-sequelize'; import { GraphQLObjectType, GraphQLString, GraphQLInt, GraphQLList, GraphQLNonNull } from 'graphql'; import { DataTypes, Sequelize } from 'sequelize'; const sequelize = new Sequelize(process.env.DB_URL ?? 'sqlite::memory:'); const User = sequelize.define('user', { id: { type: DataTypes.INTEGER, primaryKey: true, autoIncrement: true }, name: { type: DataTypes.STRING } }); const userType = new GraphQLObjectType({ name: 'User', fields: { id: { type: new GraphQLNonNull(GraphQLInt) }, name: { type: GraphQLString } } }); const query = new GraphQLObjectType({ name: 'Query', fields: { user: { type: userType, args: { id: { type: GraphQLInt } }, resolve: resolver(User) } } }); // graphqlHTTP({ schema: new GraphQLSchema({ query }) })
Debug
Known issues
deprecatedgraphql-sequelize is no longer actively maintained; consider migrating to Nexus or TypeGraphQL with Prisma.
fix
Migrate to modern alternatives; no future updates expected.
affects: >=9.0.0
breakingVersion 9.x drops support for Node.js < 12 and requires Sequelize >=6.
fix
Update Node.js to >=12 and Sequelize to >=6.
affects: >=9.0.0
gotchaNot using dataloader-sequelize will cause N+1 query performance issues.
fix
Install and integrate dataloader-sequelize alongside graphql-sequelize.
affects: *
breakingDefault export changed from a function to an object in v9; named imports now required for resolver and helpers.
fix
Use import { resolver } from 'graphql-sequelize' instead of import resolver from 'graphql-sequelize'.
affects: >=9.0.0 <9.3.0
gotchaThe 'before' hook modifies findOptions directly; mutations to nested objects may be lost if not careful.
fix
Always return the modified findOptions from the before hook.
affects: *
Errors
Common errors & fixes
TypeError: Cannot read properties of undefined (reading 'prototype')
Missing graphql peer dependency or incompatible version.
fix
Install graphql@^15 or ^16 and ensure it's in node_modules.
Cannot find module 'graphql-relay'
Missing graphql-relay peer dependency when Relay connection is used.
fix
Install graphql-relay with `npm install graphql-relay`.
SequelizeDatabaseError: column "id" does not exist
Model might not have a primary key or resolver expects 'id' field but model uses different column name.
fix
Explicitly set primary key or use 'before' hook to map args.
Upgrade
Version history
9.3.4-hack05latest on npm
Audit
Dependencies
graphqlrequiredPeer dependency required for GraphQL types and resolvers
graphql-relayoptionalRequired for Relay connection handling
sequelizerequiredORM for database models
dataloader-sequelizeoptionalStrongly recommended to avoid N+1 queries, though not a direct dependency
Agent activity
7 hits · last 30 days
node
6
Amazon
1
Resources
jonmagic-graphql-sequelize — npm install jonmagic-graphql-sequelize · libregistry