Skip to main content
coding advanced

Design Production-Ready GraphQL Schema

Generate comprehensive GraphQL schemas with types, queries, mutations, and subscriptions. Perfect for API development and database modeling.

Works with: chatgptclaudegemini

Prompt Template

You are a senior GraphQL architect tasked with designing a comprehensive GraphQL schema for [PROJECT_TYPE]. Create a production-ready schema that follows GraphQL best practices and includes proper type definitions, relationships, and operations. **Project Context:** - Application: [PROJECT_TYPE] - Primary entities: [MAIN_ENTITIES] - Key features: [KEY_FEATURES] - Authentication: [AUTH_TYPE] - Database: [DATABASE_TYPE] **Requirements:** 1. Define all necessary GraphQL types with proper scalar types and relationships 2. Create Query operations for data retrieval with filtering, pagination, and sorting 3. Design Mutation operations for CRUD operations with proper input validation 4. Include Subscription operations for real-time features if applicable 5. Implement proper error handling and field-level security 6. Add comprehensive field descriptions and deprecation notices where needed 7. Follow GraphQL naming conventions and best practices 8. Include custom scalar types if necessary 9. Design efficient resolver patterns to avoid N+1 queries 10. Add proper input validation and authorization directives **Schema Structure:** - Use interfaces and unions where appropriate - Implement Connection pattern for pagination - Include metadata fields (createdAt, updatedAt, etc.) - Design for extensibility and future feature additions - Consider performance implications of nested queries Provide the complete schema definition in GraphQL SDL format, followed by brief explanations of key design decisions and potential resolver implementation considerations.

Variables to Customize

[PROJECT_TYPE]

Type of application or project

Example: e-commerce platform

[MAIN_ENTITIES]

Primary data entities in the system

Example: User, Product, Order, Category, Review

[KEY_FEATURES]

Main features the API should support

Example: user authentication, product catalog, shopping cart, order management, reviews and ratings

[AUTH_TYPE]

Authentication method being used

Example: JWT tokens with role-based access control

[DATABASE_TYPE]

Database technology being used

Example: PostgreSQL with Prisma ORM

Example Output

```graphql scalar DateTime scalar Email scalar Money enum OrderStatus { PENDING PROCESSING SHIPPED DELIVERED CANCELLED } type User { id: ID! email: Email! firstName: String! lastName: String! orders(first: Int, after: String): OrderConnection! reviews: [Review!]! createdAt: DateTime! updatedAt: DateTime! } type Product { id: ID! name: String! description: String price: Money! category: Category! reviews(first: Int): ReviewConnection! averageRating: Float inStock: Boolean! createdAt: DateTime! } type Order { id: ID! user: User! items: [OrderItem!]! status: OrderStatus! total: Money! createdAt: DateTime! } type Query { products(filter: ProductFilter, first: Int, after: String): ProductConnection! product(id: ID!): Product me: User order(id: ID!): Order } type Mutation { createProduct(input: CreateProductInput!): Product! updateProduct(id: ID!, input: UpdateProductInput!): Product! createOrder(input: CreateOrderInput!): Order! addReview(input: AddReviewInput!): Review! } type Subscription { orderStatusUpdated(userId: ID!): Order! } ``` **Design Decisions:** - Used Connection pattern for paginated lists - Custom scalars for type safety (Email, Money, DateTime) - Proper separation of input types for mutations - Subscription for real-time order updates

Pro Tips for Best Results

  • Always define input types separately from output types to maintain schema flexibility and security
  • Use custom scalar types for domain-specific data like emails, dates, and currency to ensure type safety
  • Implement the Connection pattern for any list fields that might grow large to enable proper pagination
  • Add field descriptions and deprecation notices to make your schema self-documenting
  • Consider using interfaces and unions to reduce code duplication and improve schema maintainability

Tags

Want 500+ Expert Prompts?

Get the Premium Prompt Pack — organized, tested, and ready to use.

Get it for $29

Related Prompts You Might Like