GraphQL SDL to Zod Validation Schema Generator
Convertissez les types, requêtes et inputs GraphQL SDL en schémas de validation Zod à l'exécution (z.object, z.string, z.array) avec prise en charge avancée de la nullabilité.
import { z } from "zod";
// =========================================
// Custom Scalars
// =========================================
export const DateTimeSchema = z.string().datetime();
export type DateTime = z.infer<typeof DateTimeSchema>;
// =========================================
// Enums
// =========================================
export const CurrencySchema = z.enum(["USD", "EUR", "GBP", "JPY"]);
export type Currency = z.infer<typeof CurrencySchema>;
export const OrderStatusSchema = z.enum(["PENDING", "PROCESSING", "SHIPPED", "DELIVERED", "CANCELLED"]);
export type OrderStatus = z.infer<typeof OrderStatusSchema>;
// =========================================
// Object Types
// =========================================
export const UserSchema = z.object({
id: z.string(),
email: z.string(),
fullName: z.string(),
phoneNumber: z.string().nullish(),
addresses: z.array(AddressSchema),
primaryPaymentMethod: PaymentMethodSchema.nullish(),
createdAt: z.string().datetime(),
});
export type User = z.infer<typeof UserSchema>;
export const AddressSchema = z.object({
id: z.string(),
street: z.string(),
city: z.string(),
postalCode: z.string(),
countryCode: z.string(),
isDefault: z.boolean(),
});
export type Address = z.infer<typeof AddressSchema>;
export const MoneySchema = z.object({
amount: z.number(),
currency: CurrencySchema,
});
export type Money = z.infer<typeof MoneySchema>;
export const PaymentMethodSchema = z.object({
id: z.string(),
type: z.string(),
last4: z.string(),
expMonth: z.number().int(),
expYear: z.number().int(),
});
export type PaymentMethod = z.infer<typeof PaymentMethodSchema>;
export const OrderSchema = z.object({
id: z.string(),
orderNumber: z.string(),
customer: UserSchema,
status: OrderStatusSchema,
total: MoneySchema,
itemsCount: z.number().int(),
createdAt: z.string().datetime(),
});
export type Order = z.infer<typeof OrderSchema>;
// =========================================
// Input Object Types
// =========================================
export const CheckoutInputSchema = z.object({
userId: z.string(),
shippingAddressId: z.string(),
paymentMethodId: z.string(),
notes: z.string().nullish(),
couponCode: z.string().nullish(),
});
export type CheckoutInput = z.infer<typeof CheckoutInputSchema>;
Exécution Locale Zero-Knowledge
Tous les traitements, analyses et générations s'exécutent strictement dans la mémoire de votre navigateur. Zéro transmission vers un serveur externe.
Moteur Réactif Submilliseconde
All data payloads remain strictly local with zero external server communication.
Production Ready Export
Clean, optimized output formats ready for immediate deployment.