{"id":27067,"library":"introspectron","title":"introspectron","description":"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.","status":"active","version":"4.11.8","language":"javascript","source_language":"en","source_url":"https://github.com/constructive-io/constructive","tags":["javascript","graphql","introspection","pg","schema","graphile","constructive","typescript"],"install":[{"cmd":"npm install introspectron","lang":"bash","label":"npm"},{"cmd":"yarn add introspectron","lang":"bash","label":"yarn"},{"cmd":"pnpm add introspectron","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Used to connect to PostgreSQL for introspection","package":"pg","optional":false},{"reason":"Underlying engine for schema generation","package":"graphile-build","optional":true},{"reason":"Adds ordering by related tables","package":"@graphile-contrib/pg-order-by-related","optional":true}],"imports":[{"note":"ESM import is the standard for v4; CommonJS require works but is not recommended.","wrong":"const introspectron = require('introspectron')","symbol":"introspectron","correct":"import { introspectron } from 'introspectron'"},{"note":"buildSchema is a named export, not a default export.","wrong":"import buildSchema from 'introspectron/buildSchema'","symbol":"buildSchema","correct":"import { buildSchema } from 'introspectron'"},{"note":"Note the capitalization: generateSDK, not generateSdk.","wrong":"import { generateSdk } from 'introspectron'","symbol":"generateSDK","correct":"import { generateSDK } from 'introspectron'"},{"note":"For type-only imports, use the 'type' modifier to avoid runtime bundling.","wrong":"import { IntrospectionOptions } from 'introspectron'","symbol":"IntrospectionOptions","correct":"import type { IntrospectionOptions } from 'introspectron'"}],"quickstart":{"code":"import { introspectron } from 'introspectron';\nimport { Pool } from 'pg';\n\nconst pool = new Pool({\n  connectionString: process.env.DATABASE_URL ?? 'postgres://localhost/mydb',\n});\n\nasync function main() {\n  const result = await introspectron(pool, {\n    schemas: ['public'],\n    output: 'graphql',\n    watch: false,\n  });\n  console.log(JSON.stringify(result.schema, null, 2));\n}\n\nmain().catch(console.error);","lang":"typescript","description":"Introspects a PostgreSQL database and logs the generated GraphQL schema."},"warnings":[{"fix":"Access result.schema instead of the whole result.","message":"In v4, the output format changed from JSON string to an object with 'schema' and 'sdk' properties.","severity":"breaking","affected_versions":">=4.0.0"},{"fix":"Use the 'introspectron' named export instead.","message":"The 'introspection' function is deprecated in favor of 'introspectron'.","severity":"deprecated","affected_versions":">=4.10.0"},{"fix":"Grant SELECT on pg_catalog tables to the user.","message":"The introspection requires a database connection with read access to system catalogs. Ensure the user has appropriate permissions.","severity":"gotcha","affected_versions":"*"},{"fix":"Upgrade Node.js to version 14 or above.","message":"Node.js 12 is no longer supported; requires Node.js 14 or higher.","severity":"breaking","affected_versions":">=4.11.0"},{"fix":"Handle WebSocket connections when using watch: true.","message":"The 'watch' option in v4+ returns a WebSocket URL instead of a polling endpoint.","severity":"gotcha","affected_versions":">=4.0.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Run npm install pg","cause":"Missing peer dependency 'pg'","error":"Error: Cannot find module 'pg'"},{"fix":"Use import { introspectron } from 'introspectron'","cause":"Incorrect import: using default import instead of named import","error":"TypeError: introspectron is not a function"},{"fix":"Check DATABASE_URL environment variable or pool config","cause":"Invalid database credentials in connection string","error":"Error: Database connection failed: password authentication failed for user"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}