Registry / database / date-graphql-sequelize

date-graphql-sequelize

JSON →
library9.4.4jsnpmunverified

GraphQL & Relay integration for MySQL and Postgres via Sequelize. Current stable version is 9.4.4, released periodically. It provides resolver helpers that automatically convert GraphQL arguments to Sequelize where clauses, supports Relay connections, and includes before/after hooks for query manipulation. Designed to work with dataloader-sequelize to avoid N+1 queries. Key differentiators: seamless integration between GraphQL and Sequelize, automatic arg-to-where conversion, and built-in Relay support.

npm install date-graphql-sequelize
INSTALL
IMPORT
SIG · DATE-GRAPHQL-SEQUE
D
date-graphql-sequelize
databasejavascriptv9.4.4
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
Package is ESM-first, tree-shakeable. CommonJS require works but may break in strict CJS environments.
attributeFields
import { attributeFields } from 'graphql-sequelize'
const attributeFields = require('graphql-sequelize').attributeFields
Used to auto-generate GraphQL fields from Sequelize model attributes.
defaultListArgs
import { defaultListArgs } from 'graphql-sequelize'
const defaultListArgs = require('graphql-sequelize').defaultListArgs
Often used with attributeFields to add pagination args.

Creates a GraphQL schema with Sequelize models using resolver and attributeFields helpers.

import { resolver, attributeFields } from 'graphql-sequelize'; import { GraphQLObjectType, GraphQLSchema, GraphQLList } from 'graphql'; import { Sequelize, DataTypes } from 'sequelize'; // Setup Sequelize const sequelize = new Sequelize('database', 'user', 'password', { dialect: 'postgres' }); const User = sequelize.define('user', { name: DataTypes.STRING }); const Task = sequelize.define('task', { title: DataTypes.STRING }); User.hasMany(Task, { as: 'tasks' }); // Define GraphQL types const taskType = new GraphQLObjectType({ name: 'Task', fields: attributeFields(Task) }); const userType = new GraphQLObjectType({ name: 'User', fields: { ...attributeFields(User), tasks: { type: new GraphQLList(taskType), resolve: resolver(User.associations.tasks) } } }); const schema = new GraphQLSchema({ query: new GraphQLObjectType({ name: 'Query', fields: { users: { type: new GraphQLList(userType), resolve: resolver(User) } } }) });
Debug
Known issues
breakinggraphql-sequelize requires Sequelize >=3.0.0 and older versions of graphql (^0.5.0–^0.13.0 or ^14). It does not yet support GraphQL v15 or v16.
fix
Use graphql@14 or lower. For v15+, check for updated version of graphql-sequelize or alternative library.
affects: >=9.0.0
gotchaThe resolver only converts args to where if the key matches a model attribute; unexpected behavior with non-attribute args.
fix
Use before hook to manually handle custom args.
affects: *
deprecatedUsing resolver without options may default list detection incorrectly in older versions.
fix
Upgrade to latest or explicitly set list option.
affects: <9.0.0
gotchaThe package does not ship with TypeScript declarations; you may need to create custom typing or use @types/graphql-sequelize if available.
fix
Add declare module 'graphql-sequelize' or use @types/graphql-sequelize from DefinitelyTyped.
affects: *
gotchaWhen using Relay connections, handleConnection defaults to true; if not using Relay, set handleConnection: false to avoid unexpected errors.
fix
Pass { handleConnection: false } in resolver options if your field is not a Relay connection.
affects: >=9.0.0
breakingThe dataloader-sequelize integration is recommended but not automatically included; missing it can cause N+1 queries.
fix
Install and configure dataloader-sequelize alongside graphql-sequelize.
affects: *
deprecatedUse of resolver.contextToOptions is now considered legacy; prefer passing options per resolver.
fix
Use contextToOptions option inside resolver() call instead.
affects: >=9.0.0
Errors
Common errors & fixes
Cannot find module 'graphql-sequelize'
Package not installed or missing dependencies.
fix
npm install graphql-sequelize
Error: Schema must contain uniquely named types but contains multiple types named "Node".
Conflicting Node interface when using Relay without proper type registration.
fix
Ensure only one Node interface is defined, or use globalIdField with unique type names.
TypeError: (0 , _graphqlSequelize.resolver) is not a function
Incorrect import or destructuring; likely using CommonJS require incorrectly.
fix
Use import { resolver } from 'graphql-sequelize' or const { resolver } = require('graphql-sequelize').
Error: Cannot query across tables. Missing foreign key.
Sequelize association not properly defined or missing foreign key constraint.
fix
Check that associations are correctly defined and foreign keys exist in the database.
Unknown arg 'limit' in field 'users'.
Resolve helper not converting limit arg because list option not set or resolver not used.
fix
Ensure resolver is used for the field and list option is correctly set (or auto-detected).
Upgrade
Version history
9.4.4latest on npm
Audit
Dependencies
graphqlrequiredPeer dependency - core GraphQL library
graphql-relayrequiredPeer dependency - for Relay connection support
sequelizerequiredPeer dependency - ORM for database models
dataloader-sequelizeoptionalRecommended to avoid N+1 queries
Agent activity
7 hits · last 30 days
node
6
Amazon
1
Resources
date-graphql-sequelize — npm install date-graphql-sequelize · libregistry