GraphQL → Prisma
Fullstack Database & Prisma ORM Engineering Suite

GraphQL SDL to Prisma Schema Converter (Models & Relations)

Translate GraphQL schema definition language (SDL) object types, enums, and directives into clean Prisma ORM models and relations.

100% Client-Side Privacy
Zero Server Transmission
Presets:
Prisma Generator & ORM Options
postgresql•CUID
GraphQL Schema Definition (SDL)
// This is your Prisma schema file,
// learn more about it in the docs: https://pris.ly/d/prisma-schema

generator client {
  provider = "prisma-client-js"
}

datasource db {
  provider = "postgresql"
  url      = env("DATABASE_URL")
}

enum Role {
  OWNER
  ADMIN
  MEMBER
  VIEWER
}

enum SubscriptionStatus {
  TRIALING
  ACTIVE
  PAST_DUE
  CANCELED
}

model User {
  id String @id @default(cuid())
  email String @unique
  name String?
  avatarUrl String?
  createdAt DateTime @default(now())
  updatedAt DateTime @updatedAt

  memberships Membership[]
  ownedWorkspaces Workspace[]
  auditLogs AuditLog[]
}

model Workspace {
  id String @id @default(cuid())
  slug String @unique
  name String
  ownerId String
  subscription Subscription?
  createdAt DateTime @default(now())
  updatedAt DateTime @updatedAt

  owner User @relation(fields: [ownerId], references: [id])
  memberships Membership[]
  projects Project[]
}

model Membership {
  id String @id @default(cuid())
  role Role
  userId String
  workspaceId String
  createdAt DateTime @default(now())

  user User @relation(fields: [userId], references: [id])
  workspace Workspace @relation(fields: [workspaceId], references: [id])
}

model Invoice {
  id String @id @default(cuid())
  subscription Subscription
  subscriptionId String
  amountDue Float
  amountPaid Float
  paid Boolean
  pdfUrl String?
  createdAt DateTime @default(now())
}

model Project {
  id String @id @default(cuid())
  workspaceId String
  name String
  description String?
  createdAt DateTime @default(now())
  updatedAt DateTime @updatedAt

  workspace Workspace @relation(fields: [workspaceId], references: [id])
}

model AuditLog {
  id String @id @default(cuid())
  userId String
  action String
  ipAddress String?
  createdAt DateTime @default(now())

  user User @relation(fields: [userId], references: [id])
}
GraphQL Types Parsed8 DefinitionsObject types, enums, unions, and interfaces detected in SDL
Prisma Models Synthesized6 Models & 10 RelationsClean ORM models mapped with relational foreign keys
Zero Server Transmission100% Client-SidePure client-side AST compilation in local browser memory

Zero-Knowledge Local Execution

All data processing, parsing, and compilation execute strictly inside your local browser memory. Zero external server uploads.

Sub-Millisecond AST Engine

All data payloads remain strictly local with zero external server communication.

Production Ready Export

Clean, optimized output formats ready for immediate deployment.

Technical Reference & Architecture Guide

GraphQL SDL to Prisma Schema Converter (Models & Relations) — Reference Guide

Translate GraphQL schema definition language (SDL) object types, enums, and directives into clean Prisma ORM models and relations.

Key Parameters & Controls

ID Generation StrategyEnum (cuid | uuid | autoincrement)

Determines the primary key ID generator attribute applied to identifier fields (@id @default(cuid()), uuid(), or autoincrement()).

Default: cuid()
Relation ModeBoolean (explicit | inferred)

Automatically generates explicit Prisma @relation(fields: [...], references: [...]) foreign keys and reverse navigation properties between models.

Default: explicit
Directive MappingBoolean (enabled | disabled)

Translates custom GraphQL schema directives (@map, @unique, @default) into corresponding native Prisma field and model attributes.

Default: enabled
DateTime Scalar MappingString (DateTime | Timestamp | Int)

Maps custom GraphQL scalar types (such as DateTime or Timestamp) to native Prisma DateTime attributes.

Default: DateTime

Pro Tips & Best Practices

Bidirectional Relation Pairing

When defining 1:N or M:N relationships in GraphQL SDL, the converter automatically synthesizes missing reverse references and foreign key scalar fields to satisfy strict Prisma validation rules.

GraphQL SDL fields marked

GraphQL SDL fields marked with an exclamation mark (!) translate to required Prisma fields, whereas unadorned fields are mapped to optional Prisma fields with the '?' modifier.

Database Native Enum Declarations

GraphQL 'enum' definitions convert directly into Prisma 'enum' blocks, allowing Prisma Migrate to generate native PostgreSQL or MySQL enum types automatically.

Common Gotchas & Troubleshooting

Missing reverse relation or foreign key scalar in Prisma

Prisma requires relations to be declared on both sides. If your GraphQL SDL defines only one direction (e.g., author: User), the converter automatically generates the opposite field (posts: Post[]) and foreign key (authorId).

Unrecognized custom GraphQL scalars (JSON, DateTime, UUID)

Declare custom scalars at the top of your SDL (e.g., 'scalar DateTime') or set the scalar mapping option in the tool to avoid defaulting to standard String types.

Frequently Asked Questions

How does the converter handle Many-to-Many (M:N) relationships?▼

When two GraphQL SDL types reference each other as lists (e.g., tags: [Tag!]! and posts: [Post!]!), the converter produces Prisma's implicit many-to-many relation syntax, allowing Prisma Client to manage the join table automatically.

What happens to GraphQL Query, Mutation, and Subscription types?▼

Prisma Schema is strictly a database persistence modeling language. Root operation types (Query, Mutation, Subscription) and input types are filtered out, preserving only entity types and enums.

Can I map custom table and column names with @map and @@map?▼

Yes. Custom directives or naming conventions (such as snake_case database tables mapped from camelCase GraphQL types) are preserved using Prisma's @map("column_name") and @@map("table_name") attributes.

Is my GraphQL SDL schema processed securely without server uploads?▼

Yes. All parsing, lexical tokenization, and Prisma schema generation run 100% locally in your browser memory. No proprietary schema definitions or business logic ever leave your machine.

Related Tools & Utilities

All Tools →