GraphQL to TypeScript Converter
Convert GraphQL SDL schemas to TypeScript interfaces, types, enums, and operations. Paste your schema and get typed code instantly.
// ── Scalars ──
export type DateTime = string;
// ── Enums ──
export enum UserRole {
ADMIN = "ADMIN",
EDITOR = "EDITOR",
AUTHOR = "AUTHOR",
READER = "READER",
}
// ── Types ──
/** A blog post */
export interface Post {
id: string;
title: string;
content: string;
slug: string;
published: boolean;
createdAt: string;
updatedAt?: string;
author: User;
tags: Tag[];
comments: Comment[];
}
export interface User {
id: string;
name: string;
email: string;
avatar?: string;
bio?: string;
posts: Post[];
role: UserRole;
}
export interface Comment {
id: string;
body: string;
author: User;
post: Post;
createdAt: string;
}
export interface Tag {
id: string;
name: string;
slug: string;
posts: Post[];
}
// ── Input Types ──
export interface CreatePostInput {
title: string;
content: string;
slug?: string;
published?: boolean;
tagIds?: string[];
}
export interface UpdatePostInput {
title?: string;
content?: string;
slug?: string;
published?: boolean;
tagIds?: string[];
}
// ── Operations ──
export interface Query {
/** Args: (limit: number, offset: number, published: boolean) */
posts: Post[];
/** Args: (id: string) */
post?: Post;
users: User[];
/** Args: (id: string) */
user?: User;
tags: Tag[];
}
export interface PostsArgs {
limit?: number;
offset?: number;
published?: boolean;
}
export interface PostArgs {
id: string;
}
export interface UserArgs {
id: string;
}
export interface Mutation {
/** Args: (input: CreatePostInput) */
createPost: Post;
/** Args: (id: string, input: UpdatePostInput) */
updatePost?: Post;
/** Args: (id: string) */
deletePost: boolean;
/** Args: (name: string, email: string, password: string) */
register: User;
}
export interface CreatePostArgs {
input: CreatePostInput;
}
export interface UpdatePostArgs {
id: string;
input: UpdatePostInput;
}
export interface DeletePostArgs {
id: string;
}
export interface RegisterArgs {
name: string;
email: string;
password: string;
}
4
Types
2
Inputs
1
Enums
0
Unions
0
Interfaces
1
Scalars
2
Operations
45
Fields
Press Ctrl+Enter to copy
Default Scalar Mappings
Related Convert Tools
OpenAPI to TypeScript
Convert OpenAPI 3.x and Swagger 2.0 specs to TypeScript interfaces and types with $ref resolution, allOf/oneOf/anyOf, enums, and API operation types
JSON to Zod Converter
Convert JSON or JSON Schema to Zod validation schemas with $ref resolution, allOf/oneOf/anyOf, enum, format constraints, and required/optional fields
TypeScript to JavaScript
Convert TypeScript to JavaScript — strip types, interfaces, enums, generics, and access modifiers to get clean JS output
JSON to SQL Converter
Convert JSON arrays to SQL CREATE TABLE and INSERT statements for PostgreSQL, MySQL, and SQLite with automatic type inference