Skip to main content

GraphQL Schema Generator

TalkingSchema's AI copilot generates a complete GraphQL SDL from your entity relationship diagram — including type definitions derived from tables, enum declarations, Query root type with common read operations, Mutation root type with create/update/delete operations, input types for mutations, and connection/pagination types. The AI explains every mapping assumption, so you control the final API contract.

Outputs are provided as SDL code blocks, with an option to download as a .graphql file coming soon


How to Generate a GraphQL Schema

Full schema with queries and mutations

Generate a GraphQL SDL for this ERD. Include:
- Object types for every table
- Enum types matching database enums
- Query type: node lookup by ID, paginated list queries with filters
- Mutation type: create, update, delete for each resource
- Input types for all mutations
- Connection types for paginated results

Types only (no operations)

Generate GraphQL type definitions and enum declarations for this schema.
Do not include Query or Mutation types — I'll define those manually.

Code-first resolver signatures (TypeScript)

Generate GraphQL SDL plus TypeScript resolver type signatures
compatible with Apollo Server 4 / GraphQL Yoga.

Example Output

Using the Global Sustainable Supply Chain (GSSC) schema:

# schema.graphql

# --- Enums ---

enum CarbonTier {
A
B
C
D
}

enum CustomerTier {
enterprise
mid_market
smb
}

enum OrderStatus {
draft
confirmed
shipped
received
cancelled
}

# --- Object Types ---

type Supplier {
supplierId: ID!
companyName: String!
country: String!
carbonTier: CarbonTier!
certification: String
isActive: Boolean!
createdAt: String!
updatedAt: String!
# Relationships
products: [Product!]!
purchaseOrders: [PurchaseOrder!]!
}

type Product {
productId: ID!
sku: String!
name: String!
category: String!
unitWeightKg: Float
unitCostUsd: Float!
carbonIntensityScore: Float
isActive: Boolean!
createdAt: String!
updatedAt: String!
# Relationships
supplier: Supplier!
purchaseOrderItems: [PurchaseOrderItem!]!
salesOrderItems: [SalesOrderItem!]!
inventory: [Inventory!]!
}

type PurchaseOrder {
poId: ID!
orderDate: String!
expectedDelivery: String
status: OrderStatus
createdAt: String!
updatedAt: String!
# Relationships
supplier: Supplier!
warehouse: Warehouse!
items: [PurchaseOrderItem!]!
shipments: [Shipment!]!
}

type PurchaseOrderItem {
itemId: ID!
quantity: Int!
unitCostUsd: Float!
# Relationships
purchaseOrder: PurchaseOrder!
product: Product!
}

# --- Connection / Pagination Types ---

type SupplierConnection {
nodes: [Supplier!]!
totalCount: Int!
pageInfo: PageInfo!
}

type PageInfo {
hasNextPage: Boolean!
hasPreviousPage: Boolean!
startCursor: String
endCursor: String
}

# --- Input Types ---

input CreateSupplierInput {
companyName: String!
country: String!
carbonTier: CarbonTier!
certification: String
isActive: Boolean
}

input UpdateSupplierInput {
companyName: String
country: String
carbonTier: CarbonTier
certification: String
isActive: Boolean
}

input SupplierFilters {
carbonTier: CarbonTier
country: String
isActive: Boolean
}

input CreateProductInput {
sku: String!
name: String!
category: String!
supplierId: ID!
unitCostUsd: Float!
unitWeightKg: Float
carbonIntensityScore: Float
isActive: Boolean
}

input CreatePurchaseOrderInput {
supplierId: ID!
warehouseId: ID!
orderDate: String!
expectedDelivery: String
status: OrderStatus
}

input AddPurchaseOrderItemInput {
poId: ID!
productId: ID!
quantity: Int!
unitCostUsd: Float!
}

# --- Root Types ---

type Query {
supplier(id: ID!): Supplier
suppliers(
filters: SupplierFilters
first: Int
after: String
): SupplierConnection!

product(id: ID!): Product
products(
category: String
supplierId: ID
first: Int
after: String
): ProductConnection!

purchaseOrder(id: ID!): PurchaseOrder
purchaseOrders(
supplierId: ID
warehouseId: ID
status: OrderStatus
first: Int
after: String
): PurchaseOrderConnection!
}

type Mutation {
createSupplier(input: CreateSupplierInput!): Supplier!
updateSupplier(id: ID!, input: UpdateSupplierInput!): Supplier!
deleteSupplier(id: ID!): Boolean!

createProduct(input: CreateProductInput!): Product!
updateProduct(id: ID!, input: UpdateProductInput!): Product!
deleteProduct(id: ID!): Boolean!

createPurchaseOrder(input: CreatePurchaseOrderInput!): PurchaseOrder!
addPurchaseOrderItem(input: AddPurchaseOrderItemInput!): PurchaseOrderItem!
updatePurchaseOrderStatus(id: ID!, status: OrderStatus!): PurchaseOrder!
deletePurchaseOrder(id: ID!): Boolean!
}

Customizing the Output

RequirementPrompt addition
Relay-spec pagination"Use Relay cursor-based pagination with Connection, Edge, and Node types"
Subscriptions"Add Subscription types for real-time updates on order status changes"
ID as String with format"Use String scalar with format UUID instead of the ID scalar"
Custom scalar types"Add DateTime, UUID, and Decimal custom scalars"
Code-first with Pothos"Generate Pothos schema builder TypeScript code instead of SDL"
Exclude mutations"Generate a read-only schema — Query type only, no mutations"

Frequently Asked Questions

Does the schema handle many-to-many relationships?

Yes. Junction tables in the ERD (such as purchase_order_items) are represented as connection types with edge-level properties. Ask the AI to expose them directly or resolve them as nested arrays depending on your use case.

How are DECIMAL columns mapped in GraphQL?

By default, DECIMAL maps to Float. For monetary or high-precision values, ask: "Use a Decimal custom scalar for all DECIMAL columns." The AI generates the scalar declaration and a usage note.

Can I use this with federation (Apollo Federation)?

Yes. Ask: "Generate an Apollo Federation 2 subgraph schema. Add @key directives for all entity types." The AI produces the appropriate @key and @extends directives based on your ERD's primary key structure.