Getting Started
Relevant source files
The following files were used as context for generating this wiki page:
Nestjs-Query is a collection of NestJS packages that provide tools to simplify the creation of GraphQL and REST CRUD (Create, Read, Update, Delete) endpoints. It reduces boilerplate by providing common patterns for querying, sorting, and paging data across various persistence layers.
The project operates as a TypeScript monorepo using Yarn workspaces and Nx to manage multiple integrated packages. Developers use these packages to build scalable APIs with built-in support for TypeORM, Sequelize, Mongoose, and Typegoose.
Sources: README.md:1-20, AGENTS.md:3-6
Core Architecture
The system consists of a framework-independent core and specialized integration packages. The core package defines the interfaces and utility types, while integration packages provide specific implementations for GraphQL, REST, and various databases.
The diagram above shows the dependency relationship where all specialized packages rely on the core primitives.
Sources: README.md:22-35, AGENTS.md:24-28
Package Summary
| Package Name | Purpose |
|---|---|
@ptc-org/nestjs-query-core | Framework-independent query, service, and DTO primitives. |
@ptc-org/nestjs-query-graphql | Provides GraphQL CRUD resolvers and decorators. |
@ptc-org/nestjs-query-rest | Provides REST CRUD controller implementations. |
@ptc-org/nestjs-query-typeorm | Implementation of services using TypeORM. |
@ptc-org/nestjs-query-mongoose | Implementation of services using Mongoose. |
Sources: README.md:22-35, AGENTS.md:24-28, packages/core/README.md:12-14
Environment Setup
To begin development on the nestjs-query codebase, you must initialize the monorepo dependencies and build the internal packages.
- Clone the repository.
- Install dependencies: Run
npm installoryarn. - Bootstrap the project: Run
npm run bootstrap. - Build packages: Run
npm run buildoryarn nx run-many --target=build --all.
Sources: CONTRIBUTING.md:105-110, README.md:43-45
Development Workflow
The project uses Nx for task execution and Conventional Commits for version control. You must follow specific linting and testing procedures to ensure code quality.
Commits and Validation
All commits must follow the format <type>(<scope>): <subject>. Before submitting changes, you must validate the affected project:
- Lint:
yarn nx lint <project> - Unit Tests:
yarn nx test <project> - Build:
yarn nx build <project>
Sources: AGENTS.md:16-22, CONTRIBUTING.md:167-175
Testing Infrastructure
Testing is divided into unit tests and End-to-End (E2E) tests. E2E tests often require backing services like MySQL or PostgreSQL, which are managed via Docker.
This sequence shows the requirement of starting backing services before executing integration tests.
Sources: CONTRIBUTING.md:136-155, AGENTS.md:19-22
Documentation Structure
The documentation site is built using Docusaurus. If you add a new feature, you must update the documentation in the documentation/ directory and register new pages in documentation/sidebars.js.
The documentation is organized into the following categories:
- Introduction: Installation guides and high-level examples.
- Concepts: Core primitives like DTOs, Queries, and Services.
- Persistence: Database-specific implementation details (TypeORM, Sequelize, etc.).
- GraphQL/REST: Specifics for API endpoint generation and hooks.
Sources: CONTRIBUTING.md:180-205, documentation/sidebars.js:9-85
Summary
nestjs-query provides a modular framework for NestJS developers to generate CRUD functionality rapidly. By utilizing a shared core and specific persistence adapters, it ensures consistent API behavior for filtering, paging, and sorting regardless of the underlying database or communication protocol.