Urgent.News

What's breaking now, across thousands of outlets.

Tech

Linking SQL DDL and GraphQL Schemas Directly to Code Entities in TokenCap

AI coding assistants frequently write SQL or ORM queries that look plausible but fail at runtime because a column was renamed from created_at to createdAt or a field is non-nullable. To prevent schema-to-code drift, TokenCap implements schema linking in src/schema/schemaGraph.js . How Schema Intelligence Works DDL Parsing: Scans .sql migrations and Prisma/Drizzle schema files for CREATE TABLE…

TokenCap's AI coding assistants write SQL or ORM queries that may not function correctly at runtime due to changes in database schema such as column renaming or changes in nullability. To mitigate schema-to-code discrepancies, TokenCap employs schema linking within src/schema/schemaGraph.js. The process of schema intelligence involves parsing DDL statements in .sql migration files and Prisma/Drizzle schema files to identify table structures, including column names, data types, primary keys, and foreign keys.

Simultaneously, GraphQL schema files are analyzed to extract types, queries, and mutations. The core of schema linking lies in mapping these schema entities to corresponding backend model classes, Prisma calls, or repository queries. Upon compilation of the .tokencap/snapshot.md file, TokenCap provides a detailed Schema Entity breakdown.

For instance, the "users" table is defined in migrations/20260401_init_users.sql, featuring columns like id (UUID, Primary Key, NOT NULL), email (VARCHAR(255), UNIQUE, NOT NULL), tier (VARCHAR(50), DEFAULT 'free'), and metadata (JSONB, NULLABLE). The entity is linked to specific code entities such as src/models/User.js, src/services/auth.js (findByEmail), and src/services/billing.js (updateSubscriptionTier).

This linkage offers developers immediate access to database constraints when modifying queries or adding columns, eliminating the need for manual database dump uploads. Further details can be found at tokencap.vansharora.app.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

More from Wednesday 14 October →