This project demonstrates how to use GraphQL with .NET Core, showcasing a complete implementation of a course management system with students, courses, and course modules.
- GraphQL API with Hot Chocolate
- Entity Framework Core with SQLite database
- Domain-Driven Design architecture
- CRUD Operations for Courses, Students, and Course Modules
- Real-time Subscriptions for course updates
- Error Handling with proper GraphQL error responses
- Filtering, Sorting, and Projections support
src/
├── Data/ # Database context and configurations
│ └── ApplicationDbContext.cs
├── Domain/
│ ├── Configurations/ # Entity Framework configurations
│ │ ├── CourseConfiguration.cs
│ │ ├── CourseModuleConfiguration.cs
│ │ └── StudentConfiguration.cs
│ ├── Contracts/ # DTOs, Inputs, and Payloads
│ │ ├── CourseDTO.cs
│ │ ├── CourseInputs.cs
│ │ └── CoursePayloads.cs
│ ├── Enum/ # Domain enumerations
│ │ └── ModuleStatus.cs
│ └── Model/ # Domain entities
│ ├── Course.cs
│ ├── CourseModule.cs
│ └── Student.cs
├── Extensions/ # Service registration extensions
│ └── ServiceExtensions.cs
└── GraphqlApi/ # GraphQL schema definitions
├── Common/ # Shared GraphQL components
│ ├── Payload.cs
│ ├── StudentsQuery.cs
│ └── UserError.cs
├── Mutations/ # GraphQL mutations
│ └── CourseMutations.cs
└── Subscriptions/ # GraphQL subscriptions
└── CourseModuleSubscription.cs
- .NET 9.0
- Hot Chocolate GraphQL - GraphQL server implementation
- Entity Framework Core - ORM for database operations
- SQLite - Lightweight database for development
- C# 12 - Latest language features
- .NET 9.0 SDK or later
- Visual Studio 2022 or VS Code
- SQLite (included with EF Core)
git https://github.com/Clifftech123/dotnetcore-graphql.git
cd dotnetcore-graphql
dotnet restore
dotnet ef database update
dotnet run
Navigate to https://localhost:5001/graphql
to access the GraphQL playground and explore the API.
- courses - Get all courses with filtering and sorting
- students - Get all students with their enrolled courses
- createCourse - Create a new course
- addModuleToCourse - Add a module to an existing course
- enrollStudent - Enroll a student in a course
- onCourseModuleUpdated - Real-time updates when course modules chang
- Entities with proper encapsulation and business logic
- Value Objects and Enumerations for type safety
- Domain Services for complex business operations
- Payload Pattern for mutations with error handling
- DataLoader pattern for efficient data fetching
- Filtering and Sorting capabilities
- Real-time Subscriptions for live updates
The application uses the following main entities:
- Course - Represents a course with title and modules
- CourseModule - Individual modules within a course with status tracking
- Student - Students who can enroll in courses
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add some amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
Cliff Tech - GitHub Profile
- Hot Chocolate GraphQL team for the excellent GraphQL implementation
- Microsoft for Entity Framework Core
- The .NET community for continuous inspiration