Creates optimized GraphQL schemas for complex data queries.
You are tasked with designing a GraphQL schema based on the provided information. Your goal is to create a comprehensive, well-structured, and efficient schema that follows GraphQL best practices and addresses all the given requirements.
First, review the input data:
Data Models:
{{DATA_MODELS}}
Query Requirements:
{{QUERY_REQUIREMENTS}}
Mutation Requirements:
{{MUTATION_REQUIREMENTS}}
Performance Considerations:
{{PERFORMANCE_CONSIDERATIONS}}
Now, follow these steps to create the GraphQL schema:
1. Type Definitions:
- Create GraphQL types for each data model
- Use appropriate scalar types and custom scalars if needed
- Implement interfaces and unions where applicable
- Add documentation comments for each type and field
2. Query Definitions:
- Implement query fields based on the query requirements
- Use arguments for filtering, sorting, and pagination where appropriate
- Add documentation comments for each query
3. Mutation Definitions:
- Implement mutation fields based on the mutation requirements
- Use input types for complex mutation arguments
- Add documentation comments for each mutation
4. Subscription Definitions (if needed):
- Implement subscription fields for real-time updates
- Add documentation comments for each subscription
5. Resolver Implementations:
- Provide resolver function signatures for each field that requires custom resolution
- Address N+1 query problems using techniques like batching or DataLoader
6. Pagination Implementation:
- Implement cursor-based pagination for large result sets
- Use the Relay connection specification where appropriate
7. Error Handling:
- Define custom error types if needed
- Implement proper error handling in resolver signatures
8. Authorization Considerations:
- Add comments or directives for field-level authorization
9. Best Practices and Performance Considerations:
- Implement any additional optimizations or best practices mentioned in the performance considerations
- Ensure the schema is well-organized and follows GraphQL naming conventions
Provide your complete GraphQL schema with documentation comments. Use SDL (Schema Definition Language) syntax for the schema definition. Include resolver function signatures as comments where appropriate.
Remember to:
- Follow GraphQL best practices
- Implement proper type definitions
- Include appropriate resolvers
- Address N+1 query problems
- Implement pagination for large result sets
- Include proper error handling
- Consider authorization at the field level
- Support subscription functionality if needed
Begin your schema with a comment briefly explaining its purpose and any important notes about its structure or usage.
Like this prompt? Use it in Team-GPT for free now →