Registry / database / nestjs-graphql-tools

nestjs-graphql-tools

JSON →
library0.10.2jsnpmunverified

NestJS GraphQL automation library for building performant APIs. Current stable version: 0.10.2. Actively maintained with regular releases. Key differentiators: solves N+1 problem via DataLoader integration, provides Hasura-like filtering/sorting/pagination for NestJS/GraphQL, supports polymorphic relations, and includes TypeORM integration. Automates query building with decorators, reducing boilerplate. Requires @nestjs/graphql >8.0.0 and typeorm >0.3.0 as peer dependencies. Supports Node >=16 and npm >=8.

npm install nestjs-graphql-tools
INSTALL
IMPORT
SIG · NESTJS-GRAPHQL-TOO
N
nestjs-graphql-tools
databasejavascriptv0.10.2
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

GraphqlLoader
import { GraphqlLoader } from 'nestjs-graphql-tools'
const { GraphqlLoader } = require('nestjs-graphql-tools')
Decorator for solving N+1 problem; ESM only
Loader
import { Loader } from 'nestjs-graphql-tools'
import { LoaderData } from 'nestjs-graphql-tools'
Use Loader as a parameter decorator (not LoaderData); LoaderData is the return type
GraphqlFilter
import { GraphqlFilter } from 'nestjs-graphql-tools'
import { GraphQLFilter } from 'nestjs-graphql-tools'
Case-sensitive; used for defining filter inputs
GraphqlSorting
import { GraphqlSorting } from 'nestjs-graphql-tools'
import { GraphqlSorting } from '@nestjs/graphql'
Provided by nestjs-graphql-tools, not @nestjs/graphql
Filter
import { Filter } from 'nestjs-graphql-tools'
import { Filter } from 'typeorm'
Parameter decorator for accessing filter arguments in resolvers

Shows minimal setup: import library decorators, define query resolver with filter/sorting/pagination support, and register in NestJS module.

import { Module } from '@nestjs/common'; import { GraphQLModule } from '@nestjs/graphql'; import { TypeOrmModule } from '@nestjs/typeorm'; import { UserResolver } from './user.resolver'; import { User } from './user.entity'; @Module({ imports: [ TypeOrmModule.forRoot({ type: 'sqlite', database: ':memory:', entities: [User], synchronize: true, }), GraphQLModule.forRoot({ autoSchemaFile: true, }), ], providers: [UserResolver], }) export class AppModule {} // user.resolver.ts import { Resolver, Query, Args } from '@nestjs/graphql'; import { GraphqlFilter, GraphqlSorting, Filter, Sorting, Pagination, GraphqlPagination } from 'nestjs-graphql-tools'; import { User } from './user.entity'; import { UserObjectType } from './user.dto'; @Resolver(() => UserObjectType) export class UserResolver { @Query(() => [UserObjectType]) async users( @Filter(() => UserObjectType) filter: GraphqlFilter, @Sorting(() => UserObjectType) sorting: GraphqlSorting, @Pagination() pagination: GraphqlPagination, ) { // Build query using filter, sorting, pagination return []; } }
Debug
Known issues
gotchaDecorators must be imported from 'nestjs-graphql-tools' not from '@nestjs/graphql'
fix
Import GraphqlLoader, Filter, Sorting etc. from 'nestjs-graphql-tools'
affects: >=0.0.0
gotchaLoader parameter decorator must be the first parameter in the resolver method
fix
Place @Loader() parameter before any other custom args in @ResolveField methods
affects: >=0.0.0
gotchaFilter and Sorting decorators require a function returning the object type (e.g., () => UserObjectType)
fix
Pass a function reference to the DTO class, not a class reference directly
affects: >=0.0.0
deprecatedOlder versions (<0.8) used different naming for filter/sorting decorators
fix
Upgrade to latest and use GraphqlFilter/GraphqlSorting
affects: <0.8.0
Errors
Common errors & fixes
Cannot find module 'nestjs-graphql-tools' or its corresponding type declarations.
Missing npm install or incorrect import path
fix
Run: npm install nestjs-graphql-tools --save
TypeError: Class constructor cannot be invoked without 'new'
Using CommonJS require instead of ESM import
fix
Change to: import { GraphqlLoader } from 'nestjs-graphql-tools'
Missing peer dependencies: @nestjs/graphql, typeorm
Peer dependencies not installed automatically
fix
Run: npm install @nestjs/graphql typeorm --save
No provider for EntityManager
TypeORM module not imported or configured
fix
Add TypeOrmModule.forRoot() or TypeOrmModule.forFeature() in your module imports
Upgrade
Version history
0.10.2latest on npm
Audit
Dependencies
@nestjs/graphqlrequiredPeer dependency; provides core GraphQL integration for NestJS
typeormrequiredPeer dependency; used for database interactions and entity definitions
Agent activity
7 hits · last 30 days
node
6
Resources
nestjs-graphql-tools — npm install nestjs-graphql-tools · libregistry