SQL to GraphQL Schema Generator

Convert SQL DDL to GraphQL SDL in one command. Stop writing type definitions by hand — SchemaForge reads your database schema and generates them automatically.

11 formats 310 tests MIT license Python 3.10+ No telemetry

The problem with writing GraphQL types by hand

You have a SQL schema with 20 tables. Your backend team wants a GraphQL API. Someone sits down and writes the SDL by hand — copying column names, converting VARCHAR(255) to String, BOOLEAN to Boolean, UUID to ID. Then the database schema changes and the SDL is already out of date.

SchemaForge converts SQL DDL to GraphQL SDL automatically. Each table becomes a type. Column types map to the correct GraphQL scalars. ENUMs become GraphQL enums. Nullable columns become optional fields. The conversion runs in under a second and produces output you can use directly or adjust as needed.

Quick start

1 — Install

# Install from GitHub (PyPI publishing pending)
pip install git+https://github.com/Coding-Dev-Tools/schemaforge.git

2 — Convert your SQL file

schemaforge convert --from sql --to graphql --input schema.sql --output schema.graphql

3 — Check the output

# schema.graphql — generated from your SQL DDL
type User {
  id: ID!
  email: String!
  name: String
  role: UserRole!
  createdAt: String
}

enum UserRole {
  admin
  member
  viewer
}

type Post {
  id: ID!
  authorId: ID!
  title: String!
  body: String
  publishedAt: String
}

Each SQL table maps to a GraphQL type. NOT NULL columns become non-nullable fields (!). PRIMARY KEY UUID columns map to ID. ENUM columns generate a separate enum type. Function defaults like CURRENT_TIMESTAMP and gen_random_uuid() survive the conversion.

Type mapping reference

SchemaForge maps SQL column types to GraphQL scalars using a shared internal representation. Here's how the common types convert:

SQL DDL TypeGraphQL ScalarNotes
VARCHAR(n), TEXT, CHAR(n)String
INTEGER, INT, SMALLINT, BIGINTInt
FLOAT, REAL, DOUBLEFloat
BOOLEAN, BOOLBoolean
UUIDIDMapped to GraphQL's ID scalar
TIMESTAMP, DATETIME, DATE, TIMEStringCustom DateTime scalar if preferred
JSON, JSONBJSON (custom scalar)
DECIMAL(p,s), NUMERIC(p,s)Float
ENUM('a','b','c')GraphQL enum typeAuto-generates separate enum definition
BLOB, BYTEAStringEncoded representation
Note: Relationship directives (e.g. @relationship in Neo4j GraphQL or @link in Apollo Federation) are not generated automatically — SchemaForge converts table structures and column types. You add relationship semantics afterward based on your GraphQL server's conventions.

More conversion examples

Generate GraphQL from a Prisma schema

schemaforge convert --from prisma --to graphql --input schema.prisma --output schema.graphql

Convert GraphQL back to SQL DDL

# Bidirectional — graphql → sql is fully supported
schemaforge convert --from graphql --to sql --input schema.graphql --output schema.sql

Batch convert a directory of SQL files

schemaforge check --dir ./schemas/ --canonical sql
# Checks all schema files in the directory for consistency
# Use with --canonical to verify all formats roundtrip through a single source of truth

Diff two versions of your schema

# Catch breaking changes before they land in production
schemaforge diff schema-v1.sql schema-v2.sql
# Reports added/removed/modified tables, columns, indexes, and constraints

CI integration

Add schema consistency checks to your CI pipeline to catch drift early:

# .github/workflows/schema-check.yml (excerpt)
- name: Check schema consistency
  run: |
    pip install git+https://github.com/Coding-Dev-Tools/schemaforge.git
    schemaforge diff schemas/current.sql schemas/expected.sql
    schemaforge check --dir schemas/

schemaforge diff exits non-zero when it finds differences, so the job fails if the schemas diverge. Pair it with the check command to verify consistency across all formats in a directory.

VS Code extension

The SchemaForge VS Code extension lets you preview your schema converted to all 11 formats in a side panel as you edit. Open any .sql, .prisma, or .graphql file and run SchemaForge: Show Preview from the command palette to see the GraphQL SDL output live.

How SchemaForge compares

Tool SQL → GraphQL GraphQL → SQL Bidirectional (11 formats) Local / offline Free tier
SchemaForge ✓ (CLI)
Hasura (hosted) Hosted SaaS Free plan limited
graphql-code-generator ✓ (OSS)
prisma-to-graphql (custom scripts) Partial ✓ (DIY)

Comparison based on public documentation as of June 2026. Verify current feature sets before making tool decisions.

Pricing

GraphQL SDL import/export (including the sql → graphql direction) requires Individual or higher. The free tier covers convert and diff for basic format pairs.

PlanPriceGraphQL SDLBatch modeAlembic gen
Free$0
Individual$15/mo ($12 billed annually)
Suite (all 11 tools)$49/mo ($39 billed annually)
Team (up to 5)$79/mo ($63 billed annually)

MIT license. No telemetry. Fully offline. No account required for the free tier.

Try SchemaForge

Free tier available — install in 30 seconds, no account required.

View on GitHub →

Frequently asked questions

Can SchemaForge convert SQL to GraphQL automatically?
Yes. SchemaForge reads SQL DDL and generates GraphQL SDL type definitions, converting column types to the correct GraphQL scalars (String, Int, Float, Boolean, ID). It handles ENUMs, UUID columns, nullable fields, and function defaults like CURRENT_TIMESTAMP and gen_random_uuid().
What SQL dialects are supported?
SchemaForge's SQL parser handles standard DDL including CREATE TABLE, MySQL-specific options (ENGINE=InnoDB, AUTO_INCREMENT, DEFAULT CHARSET), inline ENUM columns, and table COMMENT. Function defaults (NOW(), gen_random_uuid()) are preserved using an internal fn: prefix convention so they survive roundtrips.
Does it handle relationships and foreign keys?
SchemaForge converts table structures and column types to their GraphQL equivalents. Relationship directives vary by GraphQL server (Apollo Federation @link, Neo4j @relationship, etc.), so those are not auto-generated — you add them manually after the initial conversion, which takes seconds per relationship.
Can I convert GraphQL SDL back to SQL?
Yes — all 110 direction pairs are supported bidirectionally. schemaforge convert --from graphql --to sql --input schema.graphql works the same as the reverse. Roundtrips go through a shared internal representation with zero data loss.
Is the GraphQL SDL output standard?
SchemaForge generates standard SDL that any GraphQL server can consume — Apollo Server, GraphQL Yoga, Strawberry, Mercurius, etc. You may need to add server-specific directives (resolvers, federation annotations) depending on your stack, but the type definitions and enums are plain SDL.
Is SchemaForge free?
The free tier covers basic convert and diff for individual use at a rate limit. GraphQL SDL import/export, batch directory conversion, and Alembic migration generation require Individual ($15/mo) or higher. MIT license, no telemetry, fully offline — no account required for the free tier.
Can I use SchemaForge in an AI coding agent?
Yes — SchemaForge ships an MCP server (schemaforge mcp) that exposes convert, diff, check, formats, and detect_format as tools. It works with Claude Code, Cursor, and any MCP-compatible AI client. Install with pip install "schemaforge[mcp] @ git+https://github.com/Coding-Dev-Tools/schemaforge.git".