{"id":41169,"library":"graphile-schema","title":"Graphile Schema","description":"A utility library for building GraphQL SDL (Schema Definition Language) from PostgreSQL databases using PostGraphile v5. It provides a `SchemaBuilder` class that simplifies constructing GraphQL schemas programmatically by introspecting database schemas and generating types and relationships. Key differentiators: integrates directly with PostGraphile v5's plugin system, eliminates manual schema stitching, and supports dynamic schema generation. Current stable version (1.22.1) is actively maintained with weekly releases. Ships TypeScript types and is part of the Constructive ecosystem.","status":"active","version":"1.22.1","language":"javascript","source_language":"en","source_url":"https://github.com/constructive-io/constructive","tags":["javascript","graphile","schema","graphql","sdl","postgraphile","introspection","constructive","typescript"],"install":[{"cmd":"npm install graphile-schema","lang":"bash","label":"npm"},{"cmd":"yarn add graphile-schema","lang":"bash","label":"yarn"},{"cmd":"pnpm add graphile-schema","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"PostGraphile v5 is a peer dependency for schema introspection and plugin support.","package":"postgraphile","optional":true}],"imports":[{"note":"ESM-only since v1. ESM imports are required; CommonJS require() will fail in Node >=12.","wrong":"const { SchemaBuilder } = require('graphile-schema');","symbol":"SchemaBuilder","correct":"import { SchemaBuilder } from 'graphile-schema';"},{"note":"Default export is not supported. Use named import.","wrong":"import buildSchema from 'graphile-schema';","symbol":"buildSchema","correct":"import { buildSchema } from 'graphile-schema';"},{"note":"TypeScript users should use 'import type' for type-only imports to avoid bundle bloat in ESM.","wrong":"","symbol":"SchemaType","correct":"import type { SchemaType } from 'graphile-schema';"}],"quickstart":{"code":"import { SchemaBuilder } from 'graphile-schema';\nimport { createPostGraphileSchema } from 'postgraphile';\n\nconst builder = new SchemaBuilder();\nconst schema = await createPostGraphileSchema(process.env.DATABASE_URL ?? 'postgres://localhost/mydb', { plugins: [builder.plugin] });\nconst sdl = builder.toSDL();\nconsole.log(sdl);","lang":"typescript","description":"Creates a SchemaBuilder instance, uses PostGraphile v5 to generate a schema from a PostgreSQL database, then outputs the SDL string."},"warnings":[{"fix":"Replace require() with import statements.","message":"Version 1.0.0 dropped support for CommonJS. All imports must use ESM syntax.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Update calls to use the new configuration object format.","message":"The 'buildSchema' function signature changed in v1.20.0; old parameters are deprecated.","severity":"deprecated","affected_versions":"<1.20.0"},{"fix":"Instantiate a new SchemaBuilder per request or use a pool.","message":"SchemaBuilder is not thread-safe. Do not share instances across concurrent requests.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Upgrade Node.js or use an older version of the package (pre-1.0).","message":"Requires Node.js >=16.0.0.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"search_vec":"'1.22.1':61 'activ':63 'build':7 'class':23 'construct':26,76,85 'current':58 'databas':15,32 'definit':11 'differenti':40 'direct':42 'dynam':55 'ecosystem':77 'elimin':49 'generat':35,57 'graphil':1,79 'graphql':8,27,81 'integr':41 'introspect':31,84 'javascript':78 'key':39 'languag':12 'librari':5 'maintain':64 'manual':50 'part':73 'plugin':47 'postgraphil':17,44,83 'postgresql':14 'programmat':29 'provid':20 'relationship':38 'releas':67 'schema':2,10,28,33,51,56,80 'schemabuild':22 'sdl':9,82 'ship':68 'simplifi':25 'stabl':59 'stitch':52 'support':54 'system':48 'type':36,70 'typescript':69,86 'use':16 'util':4 'v5':18,45 'version':60 'week':66","created_at":"2026-06-04T18:51:06.586385+00:00","updated_at":"2026-06-04T18:51:06.586385+00:00","problems":[{"fix":"Change require('graphile-schema') to import { SchemaBuilder } from 'graphile-schema'.","cause":"CommonJS require() used instead of ESM import","error":"Error: Cannot find module 'graphile-schema'"},{"fix":"Ensure you pass builder.plugin to the PostGraphile schema creation options.","cause":"Missing or incorrect PostGraphile plugin configuration","error":"TypeError: (intermediate value).plugin is not a function"},{"fix":"Add \"type\": \"module\" to package.json or use dynamic import().","cause":"Package is ESM-only but used with CommonJS environment (e.g., Node <12 or without \"type\": \"module\")","error":"SyntaxError: Unexpected token 'export'"},{"fix":"Ensure you call createPostGraphileSchema and pass builder.plugin before calling toSDL().","cause":"SchemaBuilder instance not properly initialized or schema not built first","error":"TypeError: builder.toSDL is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/constructive-io/constructive","github":"https://github.com/constructive-io/constructive","docs":null,"changelog":null,"pypi":null,"npm":"graphile-schema","openapi_spec":null,"status_page":null,"smithery":null,"categories":["database"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-04","next_check":"2026-09-02","install_tag":null}}