# Database documentation examples Based on main `a966a6e6f`. This batch adds one browser application for Drizzle and one local application for Prisma and Prisma Utils. A small plain-object-ref schema in the same Prisma project checks the documented approach without the Prisma plugin. No database-backed playground is claimed for Prisma. ## Design Both applications model a small publication about community gardens. Maya and Leo each have an unpublished draft; three published posts share a timestamp; Nora has no profile or posts. Two posts share media uploaded by Leo. These cases make selection planning, absence, ordering, ownership and join tables observable without creating a separate project for each guide. The public author type exposes published posts and a consistently filtered count. The private Viewer interface exposes the authenticated author's email and drafts, with separate editor and author implementations. Prisma Post node lookup applies the same visibility restrictions as root fields. Drizzle Post is not a Relay node; User is the public refetchable node. ## Browser: Drizzle `plugin-drizzle` contains `schema.ts`, `tables.ts`, `database.ts`, and ten operations. The actual workspace plugin and pinned Drizzle 1.0.0-rc.5 execute SQLite through SQL.js 1.14.1. SQLite runs in WebAssembly, with no remote database, credentials, or mock ORM. Each SQL statement uses a short-lived connection; the schema retains the serialized database and releases the WASM connection in finally. Rebuilding or resetting the example creates fresh seeded state. This lightweight bridge does not implement transactions spanning several statements; applications use their normal database driver. The query runner captures SQL in Console. There is no new ORM-specific response panel or runtime provider API. Type bundling supplies the installed Drizzle and selection-mapper declarations so Monaco and runtime use the same API; the source checker resolves Drizzle to the website installation to avoid duplicate class identities from pnpm's different TypeScript peer contexts. | Operation | Observable behavior | | --- | --- | | 01-author | Public profile, published posts and nested author in one SQL statement. | | 02-aliases | Opposite relation orderings remain distinct and execute two SQL statements. | | 03-viewer | Private draft and email, both interface implementations when context changes. | | 04-pagination | Tied timestamp ordering, published-only feed and media uploader. | | 05-missing | Null profile, empty posts/count, absent author. | | 06-related-pages | Filtered related count and many-to-many media connection. | | 07-node | Refetch a public author by global ID. | `check-database-browser.mjs` checks fresh Monaco diagnostics, operation responses and SQL counts, then forward/backward/empty pages, count-only SQL, viewer isolation, edited seed data, reset, sharing, an invalid column's type error, rendered docs actions, and mobile execution. The normal browser suite also checks the operation fixtures. The dedicated check runs in `test:browser` after the normal playground checker. ## Local: Prisma and Prisma Utils `local-examples/prisma` uses Prisma 7.7.0 with its SQLite driver adapter. The local runner generates the Prisma client, Pothos types and DDL from `schema.prisma`, then creates and removes a temporary database. `prisma.config.ts` supplies the dialect configuration for migration generation. The local package installation stages built workspace packages with resolved dependency versions, because npm cannot consume `workspace:` ranges. GraphQL 16 remains isolated from the workspace. The suite checks selected relations, incompatible aliases, filtered counts, missing records, both viewer implementations, shared media/uploader, node visibility, cursor continuation/backward pages, title filters, draft creation/update, denied writes, and nested mutation payload selections. It also executes every authored operation file and the plain-ref schema. Prisma Utils shares the same schema and seed instead of adding a second application. ## Documentation preservation and review All pre-existing substantive guide content is retained. New sections connect those APIs to the publishing schemas with source-backed excerpts and concrete outcomes. Advanced alternatives remain literal documentation: async selection callbacks, conflicting type-level selections, custom connection/edge types and helpers, custom node IDs, relation variant overrides, optional-plugin integrations, and Prisma scalar-list filters (unsupported by SQLite). Package READMEs expand the source excerpts and keep API explanations, without browser/local project links, repository test commands or editing instructions. Existing Prisma Utils generator references are preserved from main. Independent design review requested separate drafts, aligned join uniqueness, removal of an unused plugin, and an accurate name for the payload mutation; all were addressed. Independent content and preservation review found missing setup imports, the Relay nodes setting, and a shared-media action that omitted one of the posts; all were addressed. Historical browser support for the pre-ORM 8 plugin was inspected at `0f2084405` and `47ac42ea2`, from the older `mh--plugin-prisma-next` work. It used SQL.js, pregenerated contracts, seed aliases, and SQL/AST panels. It targets the 0.14/0.16 client, rather than the current private ORM8 RC9 plugin. Restoring that runtime requires separate compatibility, contract-generation and lifecycle work; it is not included in this batch. ## Initial batch validation evidence - Production `build-ci` passed, including generated bundles, reference checks and website types. - `type:examples`: 89 source files across 72 isolated programs passed. - Full production playground checks: 72 programs and 130 browser operations passed, including existing mobile controls, source/step transitions, and landing-page checks. - Rendered documentation link checking found one new overview link, which was corrected; the rebuilt site passes all internal page and anchor checks. - Website unit tests: 38 passed across 13 files. - Clean `check:local`: existing local applications plus Prisma/Utils and plain refs passed. - All seven Drizzle browser operation fixtures passed with fresh editor diagnostics, SQL-count assertions, forward/backward/empty pages, viewer switching, edited data, sharing and reset. - All five rendered Drizzle source actions passed; the mobile docs action and result passed at 390px. Desktop and mobile screenshots were inspected. - All 15 source-derived excerpts were checked for exact expanded parity in package READMEs. - Independent static design/content/preservation/correctness reviews found no remaining issues after the fixes recorded above. - The focused production-browser check also passed shared-code trust/build, edited database reconstruction, and rejection of an unknown Drizzle column by the TypeScript worker. Logs for this run are under `/tmp/pothos-database-*.log` and `/tmp/pothos-drizzle-*.log`. ## Guide coverage and layout follow-up The initial batch left most original Drizzle examples disconnected from the shared app. The core guides now explain the publishing schema directly, with 18 source actions across the overview, objects, relations, selections, variants, interfaces, connections, ordering, and query planning. Relay links to the node-refetch operation. The app is split into builder, query, and type modules; source actions open and highlight the relevant file, including dedented field excerpts. Computed SQL selections and the ownership-checked User.viewer variant have dedicated operations. Advanced connection helpers and async selections have separate guide pages. Supported alternatives and original headings remain available at their original routes. The preservation comparison used original main a966a6e6f and immediate parent 2f1ed1c5c; independent review restored missing headings, explicit ownership selections, and a concrete relation-variant example. Package README excerpts and explanations were synchronized without project-running instructions. The playground toolbar shares its row with the popup close control. Guide links wrap alongside instructions, steps omit the repeated example title, and small screens use numbered steps with the active title in the guide. The console height is capped relative to the viewport. Sidebar visibility is independent of embedded branding: the homepage requests sidebar=0, while the popup and full playground show Files/Explorer on desktop and a source selector on mobile. Follow-up checks include all nine database operations, reverse-context variant ownership, 18 rendered actions with source-file selection and specific response assertions, desktop/mobile Run and Close overlap checks, file editing, SDL, previous/next steps, homepage behavior, and rendered links across 79 documentation pages. The dedented source-navigation regression has unit coverage. Final follow-up results: production build and website types passed; 94 source files across 72 isolated example programs passed; 40 unit tests passed. All nine Drizzle operations and all 18 rendered actions passed, including correct active source files, SQL counts, privacy, pagination, editing, sharing, reset, and unknown-column diagnostics. Popup controls passed at 320/390/1024px; mobile source editing and step navigation passed at 320/390px. Homepage checks passed. All 79 rendered documentation pages passed internal link/anchor checks, and all 20 expanded Drizzle source excerpts matched the package README. Desktop/mobile step and console screenshots were inspected. Formatting and git diff checks passed. ## Pothos documentation scope At the user's request, removed the database tutorial material added in this branch. Setup now assumes an existing Drizzle client and relations and documents Pothos configuration, dialect metadata, context, optional plugins, and plugin options. Tables, initialization, and browser-driver limitations remain in the runnable example and its README. General database setup links to Drizzle. Core guides remove repeated application narrative and duplicate resolver setup. Advanced pages remain because their selection and connection-helper contracts are Pothos APIs; cursor precision, query aliasing, selection dependencies, and ownership caveats are retained. Package README is synchronized, with all 18 remaining source excerpts matching. Independent scope/preservation review found no lost Pothos mechanics or dangling setup references. Production build, 147 playground references, and internal links across 79 rendered pages pass. Executable sources and launch queries are unchanged; the overview action was checked in the rebuilt browser preview. ## Fresh scope review and reading layout A fresh review removed the SQLite many-to-many query-plan subsection from guides and README. Those alias/identity-lookup internals already have source comments in relation-filter.ts and junction-key/relation-shape tests. The guides retain the public buildFilter contract instead. Also removed duplicated helper definitions, incidental index advice, and the redundant variant email-selection example. Basic variants now precede interfaces, counts distinguish root and related connections, and async selection uses a coherent preview-size example. Necessary cursor precision, filter, selection, and ownership behavior remains. All 18 source actions retain their query, source, and order; all 18 expanded README excerpts match. Untitled source snippets place Playground/Copy below the code, preserving normal top padding without covering source text. Linked ranges use persistent whole-line and gutter decorations, scroll into view, and reappear when returning to the file. Browser checks assert the highlighted start line is visible for all 18 Drizzle actions. Additional checks cover file switching, desktop and mobile controls, enlarged text, and tabbed snippets. Previous/next navigation has a measured 60px desktop and 44px mobile gap from article content. Production build, website types, formatting, and internal links across all 79 rendered pages pass. The new guide cleanup received independent source/correctness review before the final build. The snippet action placement was subsequently corrected to match normal Fumadocs snippets: Playground and Copy float together in the top-right corner. The custom action-row/footer CSS was removed; neither control adds a row above or below the source. Persistent source highlights and the separate previous/next navigation spacing remain. ## Resolver readability Expanded database-query and connection-helper resolvers across Drizzle and Prisma examples, literal guides, and package READMEs into block bodies with explicit returns and multiline query options. Dense selection callbacks were expanded as well. The initial author field is declared inside queryType({ fields }), replacing the empty queryType plus a separate queryField. The broader docs audit found two similar nested helper calls in complexity and dataloader; these now name the intermediate limit/result before returning. Trivial property projections remain concise. Independent review found no behavior change and caught one misplaced comment/brace, which was fixed. All 26 source-backed database excerpts match the package READMEs. Example typechecks (94 files/72 programs), Prisma and plain-ref behavior suites, production build, 147 reference checks, and rendered internal links across 79 pages pass. The browser suite verifies all nine Drizzle operations and all 18 source actions, including the newly formatted highlighted ranges. ## GraphQL readability and connection coverage - Formatted literal GraphQL documentation fences and matching package READMEs without changing their parsed operations. All 127 standalone example GraphQL files already matched the formatter. Documentation query overrides now open with expanded selections; annotated or incomplete overrides remain intact. Unit suite: 42 tests passed; a production-browser check confirmed the linked query is formatted and executable. - Drizzle root feed now exposes a filtered totalCount. Existing attachment rows now carry nullable per-post captions; types/attachments.ts demonstrates helper argument/filter handling, join-row pagination, Media node selection, nested uploaders, and custom edge fields without adding another example project. - The connection guides use the publishing schema throughout, with focused source links for helpers, related connections, counts and cursor traversal. Database node guides are titled Relay nodes and warn that direct lookup bypasses unrelated list/root filters. - Drizzle browser validation passed all ten operations, forward/backward/empty pagination, caption filtering, root count-only SQL, viewer isolation, reset/share and invalid-column diagnostics, all twenty rendered documentation actions, and the mobile action. A separate populated edge-only request passed without requesting node fields. Expected responses were regenerated and inspected for the added count, caption rows and cursors. - Prisma local examples include attachment edges through a dedicated connection module. Local suite and Prisma checks passed, including distinct captions for shared Media nodes, forward/backward/empty pages, nested uploader selection, root counts and populated edge-only queries. ## Relay node authorization - Added `/docs/plugins/scope-auth/relay-nodes`; the existing Scope Auth guide moved to an index without changing its URL or anchors. Drizzle and Prisma Relay nodes pages link the new guidance and warn that node loaders bypass unrelated root/list authorization. - Expanded the existing Scope Auth example with a static type scope map allowing `permission: 'readArticle'` or a parent `readFeaturedArticle` grant. Node source and builder are separate files. Operations demonstrate granted versus direct access to the same object in both selection orders, permission-based refetch, `__typename` visibility, and mixed denied/missing node lookups. - Browser experiments rejected two tempting alternatives: parent grants are not resolved at the returning-field path used by `runScopesOnType`, and evaluated type authorization callbacks are cached by object identity. The final example uses neither mechanism for its path-dependent policy. The guide explains these limitations, loader visibility, field null propagation, and request-scoped caches. - All twelve Scope Auth browser operations and Monaco diagnostics passed, independently reproduced by the guide reviewer. The targeted three-file typecheck passed. The guide opens the relevant node operations via explicit links instead of opening the example's unrelated default operation. - Final validation: production build passed; 97 source files passed across 72 isolated example programs; 149 playground references and internal links/anchors across 80 documentation pages passed. All 134 authored GraphQL operation files and 56 literal documentation fences matched formatting with preserved parsed meaning. The rendered authorization guide's op8 link opened and executed the expected granted/direct result in the rebuilt production site. ## Node defaults, source-backed actions, and documentation formats - The node authorization guide now covers generated lookup gates, Node interface scopes, Query defaults with explicit public exceptions, and disabling lookups. Seven Scope Auth runtime tests verify the differences: root gates prevent loads, default interface scopes protect fields after loading, object scopes remain additive, and Query defaults apply to generated fields. Package type checks passed; independent review reproduced the tests. - One private-policy alternative stays within the existing Scope Auth example. It combines the three baseline controls and retains a public serviceName exception. Six guide snippets include actual source and use op metadata to open the intended fixture, preserving variables/context and source highlighting. The original example continues to demonstrate path grants. All fifteen browser operations and Monaco diagnostics passed; all six rendered snippet actions passed with intended operations, contexts and highlighted files. - Snippet metadata supports op as a one-based operation index. The reference checker rejects invalid/out-of-range values and combining op with query. Existing default behavior is unchanged. The rendered-action check is part of browser CI. - The output audit verified 572 code snippets, including 174 source includes, across 80 pages: HTML with inactive tabs activated, public .mdx, internal llms.mdx, llms-full.txt, llms.txt and sitemap. All 66 source-backed package README excerpts match. Copy as Markdown matched processed text on four representative pages. Raw GitHub edit links intentionally point to authoring MDX; there are no separate historical/versioned website routes. No snippets were lost in published text; two missing Drizzle README import pairs were fixed. - check:formats now runs in browser CI. Its AST-based code-block reader handles nested MDX fences. It checks snippet content (normalizing indentation) and source-backed README parity; it does not assert literal prose parity between guides and package READMEs. Existing docs execution checks passed. - Final production build passed. Example type validation passed 100 source files across 73 isolated programs; reference validation passed 155 actions across 80 pages.