Registry / database / introspectron

introspectron

JSON →
library4.11.8jsnpmunverified

Introspectron introspects a PostgreSQL database and generates a typed SDK with GraphQL, REST, or direct SQL endpoints. The current stable version is 4.11.8, released regularly on npm. It differentiates by offering multiple output formats (GraphQL schema, REST endpoints, TypeScript SDK) from a single introspection, supporting Graphile Engine for advanced schema generation. It requires a running PostgreSQL instance and outputs code for both Node.js and browser environments.

npm install introspectron
INSTALL
IMPORT
SIG · INTROSPECTRON
I
introspectron
databasejavascriptv4.11.8
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.

introspectron
import { introspectron } from 'introspectron'
const introspectron = require('introspectron')
ESM import is the standard for v4; CommonJS require works but is not recommended.
buildSchema
import { buildSchema } from 'introspectron'
import buildSchema from 'introspectron/buildSchema'
buildSchema is a named export, not a default export.
generateSDK
import { generateSDK } from 'introspectron'
import { generateSdk } from 'introspectron'
Note the capitalization: generateSDK, not generateSdk.
IntrospectionOptions
import type { IntrospectionOptions } from 'introspectron'
import { IntrospectionOptions } from 'introspectron'
For type-only imports, use the 'type' modifier to avoid runtime bundling.

Introspects a PostgreSQL database and logs the generated GraphQL schema.

import { introspectron } from 'introspectron'; import { Pool } from 'pg'; const pool = new Pool({ connectionString: process.env.DATABASE_URL ?? 'postgres://localhost/mydb', }); async function main() { const result = await introspectron(pool, { schemas: ['public'], output: 'graphql', watch: false, }); console.log(JSON.stringify(result.schema, null, 2)); } main().catch(console.error);
introspectron --version
Debug
Known issues
breakingIn v4, the output format changed from JSON string to an object with 'schema' and 'sdk' properties.
fix
Access result.schema instead of the whole result.
affects: >=4.0.0
deprecatedThe 'introspection' function is deprecated in favor of 'introspectron'.
fix
Use the 'introspectron' named export instead.
affects: >=4.10.0
gotchaThe introspection requires a database connection with read access to system catalogs. Ensure the user has appropriate permissions.
fix
Grant SELECT on pg_catalog tables to the user.
affects: *
breakingNode.js 12 is no longer supported; requires Node.js 14 or higher.
fix
Upgrade Node.js to version 14 or above.
affects: >=4.11.0
gotchaThe 'watch' option in v4+ returns a WebSocket URL instead of a polling endpoint.
fix
Handle WebSocket connections when using watch: true.
affects: >=4.0.0
Errors
Common errors & fixes
Error: Cannot find module 'pg'
Missing peer dependency 'pg'
fix
Run npm install pg
TypeError: introspectron is not a function
Incorrect import: using default import instead of named import
fix
Use import { introspectron } from 'introspectron'
Error: Database connection failed: password authentication failed for user
Invalid database credentials in connection string
fix
Check DATABASE_URL environment variable or pool config
Upgrade
Version history
4.11.8latest on npm
Audit
Dependencies
pgrequiredUsed to connect to PostgreSQL for introspection
graphile-buildoptionalUnderlying engine for schema generation
@graphile-contrib/pg-order-by-relatedoptionalAdds ordering by related tables
Agent activity
8 hits · last 30 days
node
8
Resources
introspectron — npm install introspectron · libregistry