Registry / database / drizzle-graphql

drizzle-graphql

JSON →
library0.8.5jsnpmunverified

Automatically generate GraphQL schema or customizable schema config fields from Drizzle ORM schema. Current stable version is 0.8.5, with a moderate release cadence. It wraps Drizzle ORM tables into GraphQL types, queries, mutations, and inputs, allowing rapid GraphQL API creation. Differentiators: tight integration with Drizzle ORM, automatic schema generation with TypeScript types, and flexible customization via entities object.

npm install drizzle-graphql
INSTALL
IMPORT
SIG · DRIZZLE-GRAPHQL
D
drizzle-graphql
databasejavascriptv0.8.5
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.

buildSchema
import { buildSchema } from 'drizzle-graphql'
import buildSchema from 'drizzle-graphql'
Named export, not default export. Only ESM supported.
buildSchema
import { buildSchema } from 'drizzle-graphql'
const { buildSchema } = require('drizzle-graphql')
Package is ESM-only; CommonJS require is not supported.
entities.queries
const { entities } = buildSchema(db); entities.queries.users
Access generated queries from the entities object returned by buildSchema.
entities.types
const { entities } = buildSchema(db); entities.types.UsersItem
Entity types are Drizzle table derived GraphQLObjectType instances.

Shows how to define a Drizzle ORM table, create a database instance, build the GraphQL schema with buildSchema, and serve it with GraphQL Yoga.

import { buildSchema } from 'drizzle-graphql'; import { pgTable, integer, varchar } from 'drizzle-orm/pg-core'; import { drizzle } from 'drizzle-orm/node-postgres'; const users = pgTable('users', { id: integer('id').primaryKey(), name: varchar('name', { length: 100 }), }); const db = drizzle(process.env.DATABASE_URL ?? ''); const { schema, entities } = buildSchema(db); // Use schema directly or customize with entities // Example: host with GraphQL Yoga import { createYoga } from 'graphql-yoga'; import { createServer } from 'node:http'; const yoga = createYoga({ schema }); const server = createServer(yoga); server.listen(4000, () => console.log('Server running on http://localhost:4000/graphql'));
Debug
Known issues
breakingdrizzle-graphql requires drizzle-orm >=0.30.9 and graphql >=16.3.0
fix
Update your peer dependencies to compatible versions.
affects: >=0.8.5
deprecatedPackage is still in early active development; no deprecated features reported yet.
affects: all
gotchaThe package is ESM-only; CommonJS require will fail with ERR_REQUIRE_ESM.
fix
Use ES module syntax (import) or configure your project for ESM.
affects: >=0.8.5
gotchabuildSchema returns an object with schema and entities; entities may be undefined if schema generation fails.
fix
Always check that db is properly initialized and schema is valid.
affects: all
Errors
Common errors & fixes
Cannot find module 'drizzle-graphql'
Package not installed or types not resolved
fix
Run 'npm install drizzle-graphql' and ensure you have proper TypeScript configuration.
ERR_REQUIRE_ESM
Using require() instead of import
fix
Replace require() with import or set 'type': 'module' in package.json.
Query 'users' not found in generated schema
Table name mismatch or buildSchema not called correctly
fix
Verify your Drizzle schema exports the table with the expected name and pass db correctly to buildSchema.
Upgrade
Version history
0.8.5latest on npm
Audit
Dependencies
drizzle-ormrequiredPeer dependency required for Drizzle ORM schema and database instance
graphqlrequiredPeer dependency required for GraphQL types and schema construction
Agent activity
15 hits · last 30 days
node
12
Resources
drizzle-graphql — npm install drizzle-graphql · libregistry