Skip to content

Dendekky/graphql-codegen

Repository files navigation

GraphQL Type Generator

This is a modern GraphQL Type Generator web wrapper built with Next.js 15, featuring a stunning glassmorphism UI and comprehensive developer experience. This project eliminates the need for an extra codegen step in your development process.

✨ Features

🎨 Modern UI/UX

  • Stunning glassmorphism design with animated gradient backgrounds
  • Responsive layout that works beautifully on all devices
  • Dark/Light mode toggle with system preference detection πŸŒ™β˜€οΈ
  • Animated blob backgrounds with custom CSS animations
  • Hover effects and smooth transitions throughout
  • Clean, uncluttered interface optimized for both simple and advanced users
  • Full-height output area that expands to use all available space
  • Interactive copyable examples with hover-to-reveal copy buttons

πŸ”„ Dual Input Modes

  • GraphQL Endpoint Mode - Connect to live GraphQL APIs with custom headers
  • Schema Definition Mode - Paste GraphQL schema definitions directly
  • Seamless switching between input modes with preserved state
  • Real-time schema validation with error highlighting and helpful messages
  • Visual guidance and format hints for schema definitions
  • Line count display for schema definition input

πŸ” Schema Validation

  • Real-time validation with debounced input (300ms) for smooth typing
  • GraphQL spec compliance using official GraphQL parser
  • Visual error highlighting with dynamic border colors and status icons
  • Helpful error messages with line/column information and suggestions
  • Validation state indicators - loading, valid, error states with appropriate badges
  • Form integration - prevents generation with invalid schemas
  • User-friendly error descriptions with improvement suggestions for common mistakes

⚑ Developer Experience

  • Next.js 15 with App Router for optimal performance
  • Server Actions replacing traditional API routes
  • TypeScript support with full type safety
  • Advanced state management with Zustand for optimal performance
  • Keyboard shortcuts for power users ⌨️
    • Ctrl+Enter: Generate types
    • Ctrl+D: Download types
    • Escape: Cancel requests or clear
    • Ctrl+Shift+T: Toggle theme
    • Ctrl+/: Show shortcuts help
  • URL parameter support for quick sharing and bookmarking

πŸš€ Multiple Output Formats

  • TypeScript Types - Basic schema types (default)
  • TypeScript Operations - Query/mutation types for operations
  • GraphQL Request SDK - Ready-to-use SDK with fetch methods
  • Typed Document Node - Pre-compiled DocumentNode for better performance
  • React Query Hooks - TanStack Query hooks for React applications
  • TypeScript Resolvers - Server-side resolver type signatures
  • Smart Dependencies - Automatically includes required base plugins
  • Format Validation - Ensures operations are provided when needed

πŸ“Š Performance & Metrics

  • Real-time generation metrics (time, file size, type count)
  • Request cancellation with AbortController
  • Performance tracking using high-precision timers
  • Smart file size formatting (B/KB/MB)
  • Visual format indicators showing which formats were generated

πŸ› οΈ Functionality

  • Public & Private GraphQL endpoints with custom header support πŸ”
  • Direct schema definition input for offline development πŸ“
  • Authentication headers (Bearer tokens, API keys, custom headers)
  • GraphQL Operations Input for client SDK generation
  • Copy to clipboard with visual feedback πŸ“‹
  • Download as .ts file with proper TypeScript MIME type πŸ“
  • Error handling with user-friendly messages
  • Loading states with cancel functionality
  • State persistence - Form data persists across browser sessions

πŸ” SEO & Discoverability

  • Comprehensive metadata with targeted keywords and descriptions
  • Structured data (JSON-LD) for enhanced search engine understanding
  • Open Graph & Twitter Cards for social media sharing
  • Dynamic sitemap.xml with proper priorities and change frequencies
  • robots.txt with crawl guidelines and sitemap reference
  • Web app manifest for PWA capabilities
  • About page with detailed feature descriptions and technical information

πŸš€ Getting Started

You can find the deployed page on GraphQL Type Generator.

To run locally:

# Install dependencies
yarn install

# Run the development server
yarn dev

Open http://localhost:3000 with your browser to see the result.

πŸ“– How to Use

Online Interface

  1. Endpoint Mode:

    • Select "Endpoint URL" tab
    • Enter your GraphQL endpoint in the input field
    • Add custom headers if needed (for private APIs)
    • Click "Generate Types" or use Ctrl+Enter
  2. Schema Definition Mode:

    • Select "Schema Definition" tab
    • Paste or type your GraphQL schema directly
    • Real-time validation provides instant feedback on schema correctness
    • Visual indicators show validation status (valid/error/validating)
    • Use the provided examples as templates
    • Click "Generate Types" or use Ctrl+Enter (disabled until schema is valid)
  3. Advanced Configuration:

    • Click "Output Formats" to access advanced options
    • Select multiple output formats (TypeScript, React Query, etc.)
    • Add GraphQL operations for client SDK generation
    • Configure custom headers for authentication
  4. URL Parameter: Pass the endpoint as a query parameter:

    https://graphql-codegen.vercel.app/?graphqlApiEndpoint=https://your-api.com/graphql
    
  5. Keyboard Shortcuts: Use Ctrl+Enter to generate, Ctrl+D to download, or Ctrl+/ for help

Example Usage

Schema Definition Example (Click to copy)

type Query {
  user: User
  posts: [Post!]!
}

type User {
  id: ID!
  name: String!
  email: String!
}

type Post {
  id: ID!
  title: String!
  content: String!
  author: User!
}

Public APIs (No headers required)

  • Star Wars API: https://swapi-graphql.netlify.app/.netlify/functions/index
  • Countries API: https://countries.trevorblades.com/
  • SpaceX API: https://spacex-production.up.railway.app/

APIs with Custom Headers (Expand headers section)

  • GitHub GraphQL API: https://api.github.com/graphql
    • Header: Authorization: Bearer YOUR_GITHUB_TOKEN
  • Shopify Admin API: https://YOUR_SHOP.myshopify.com/admin/api/2023-10/graphql.json
    • Header: X-Shopify-Access-Token: YOUR_ACCESS_TOKEN
  • Hasura GraphQL: https://YOUR_HASURA_PROJECT.hasura.app/v1/graphql
    • Header: x-hasura-admin-secret: YOUR_ADMIN_SECRET

πŸ”’ Privacy & Security

  • Secure server-side processing - All GraphQL introspection happens on our servers
  • No data storage - We don't store your schemas, endpoints, or generated code
  • No tracking - We don't track your usage or collect personal information
  • Open source - Full transparency with publicly available code

πŸ—οΈ Architecture

This project uses cutting-edge web technologies:

  • Next.js 15 with App Router for superior performance and developer experience
  • Server Actions instead of API routes for type-safe server functions
  • Tailwind CSS with shadcn/ui for beautiful, accessible components
  • TypeScript for complete type safety throughout the application
  • next-themes for seamless dark/light mode switching
  • GraphQL Tools for schema parsing, introspection, and validation

πŸ› οΈ Tech Stack

🎯 Latest Features ⭐

βœ… Recently Completed

  • βœ… Real-time Schema Validation - Live validation with error highlighting and helpful messages
  • βœ… Schema Definition Input - Direct schema paste/type functionality
  • βœ… Dual Input Modes - Toggle between endpoint URL and schema definition
  • βœ… Comprehensive SEO - Metadata, structured data, sitemap, robots.txt
  • βœ… Interactive Copy Examples - Hover-to-reveal copy buttons on all examples
  • βœ… About Page - Detailed information and feature descriptions
  • βœ… Enhanced Privacy Messaging - Accurate server-side processing claims
  • βœ… Full-Height Output - Textarea expands to use all available space
  • βœ… UI Polish - Removed redundant format display, improved layout
  • βœ… Enhanced UX - Better visual guidance and error handling

πŸ“ Roadmap

🎯 Next Priority Features

  • Schema Introspection Visualization - Interactive schema explorer
  • Configuration Presets - Save and reuse common configurations
  • Auto-generation from URLs - Automatically generate when URL contains endpoint
  • Schema Suggestions - Auto-complete and intelligent schema suggestions

πŸ”§ Enhanced Developer Experience

  • Schema Diff Comparison - Compare schemas between versions
  • Batch Processing - Handle multiple endpoints simultaneously
  • Advanced Caching - Smart caching for repeated schema requests
  • Loading Skeletons - Better loading states with skeleton UI
  • Export History - Track and manage previous generations

πŸš€ Advanced Features

  • Plugin System - Custom codegen plugin integration
  • Team Collaboration - Share configurations and schemas
  • API Documentation - Auto-generate docs from schema
  • Performance Analytics - Track usage patterns and optimization

βœ… Completed Features

  • βœ… Modern UI Redesign - Glassmorphism with animated backgrounds
  • βœ… Dark/Light Mode - Theme switching with system preference
  • βœ… Copy to Clipboard - With visual feedback and success states
  • βœ… Download Functionality - Save as TypeScript files
  • βœ… Keyboard Shortcuts - Complete shortcut system with help modal
  • βœ… Performance Metrics - Real-time generation tracking
  • βœ… Request Cancellation - Abort long-running requests
  • βœ… Custom Headers Support - Authentication headers, API keys, and custom headers
  • βœ… Next.js 15 Migration - App Router with server actions
  • βœ… shadcn/ui Integration - Modern component library
  • βœ… TypeScript 5.6 - Latest TypeScript features
  • βœ… Multiple Output Formats - TypeScript, React Query, GraphQL Request, Resolvers, etc.
  • βœ… Advanced State Management - Zustand for optimal performance and clean architecture
  • βœ… Modal-based UI - Clean interface with progressive disclosure
  • βœ… GraphQL Operations Support - Client SDK generation with operation inputs
  • βœ… Smart Format Dependencies - Automatic plugin dependency resolution
  • βœ… State Persistence - Form data persists across browser sessions
  • βœ… Schema Definition Input - Direct schema paste functionality
  • βœ… Real-time Schema Validation - Live validation with GraphQL spec compliance and helpful error messages
  • βœ… Dual Input Modes - Endpoint URL and Schema Definition switching
  • βœ… SEO Optimization - Complete SEO package with metadata, structured data, sitemap
  • βœ… Copyable Examples - Interactive copy functionality for all code examples
  • βœ… Enhanced About Page - Comprehensive tool information and features
  • βœ… Privacy & Security - Accurate messaging about server-side processing
  • βœ… UI/UX Polish - Full-height output, improved layout, better visual hierarchy

🀝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request. The project is designed with extensibility in mind, making it easy to add new features.

πŸ“„ License

This project is open source and available under the MIT License.

About

An online graphql codegen that takes in the graphql endpoint and returns the proper Typescript types

Topics

Resources

Stars

Watchers

Forks