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 100 documented directions MIT license Python 3.10+

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 GraphQL scalars. ENUMs become GraphQL enums. Nullable columns become optional fields. Review the generated output before use, especially relationship details: the shared representation does not retain foreign-key constraints or ORM relationship fields.

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
Review relationship details: SchemaForge's shared representation does not retain foreign-key constraints or ORM relationship fields. Add GraphQL 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
SchemaForge ✓ ✓ ✓ ✓
Hasura (hosted) ✓ — — Hosted SaaS
graphql-code-generator — — — ✓
prisma-to-graphql (custom scripts) Partial — — ✓

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

Supported conversion scope

SchemaForge supports 11 formats and 100 documented conversion directions. Alembic is output-only. Tables, columns, types, defaults, indexes, unique constraints, and enums are preserved by the shared representation; review foreign-key constraints and ORM relationship fields after conversion because they are not retained.

Try SchemaForge

Install from source while PyPI publishing is pending.

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 — SchemaForge supports 11 formats and 100 documented conversion directions. GraphQL SDL can be converted to SQL. Review foreign-key constraints and ORM relationship fields after conversion because the shared representation does not retain them. Alembic is output-only.
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?
SchemaForge is MIT licensed and installed from source while PyPI publishing is pending. The README does not publish tier pricing; see the repository for current project information.
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".