Registry / devops / nestjs-graphql-relay

nestjs-graphql-relay

JSON →
library11.0.2jsnpmunverified

A Nest.js plugin that integrates @nestjs/graphql with graphql-relay and TypeORM, providing decorators and utilities for building Relay-compatible GraphQL APIs (connections, edges, pagination). Current stable version is 11.0.2, compatible with @nestjs/graphql >=13.1.0 and graphql-relay ^0.10.2. It simplifies creating Relay pagination by generating connection types, edge types, and page info automatically from entity definitions. Unlike manual implementation, it reduces boilerplate and ensures consistency with the Relay specification. The library is actively maintained, with releases following NestJS updates.

npm install nestjs-graphql-relay
INSTALL
IMPORT
SIG · NESTJS-GRAPHQL-REL
N
nestjs-graphql-relay
devopsjavascriptv11.0.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.

Relay
import { Relay } from 'nestjs-graphql-relay'
import Relay from 'nestjs-graphql-relay'
Relay is a namespace export, not a default export.
PageInfo
import { PageInfo } from 'nestjs-graphql-relay'
import { PageInfo } from '@nestjs/graphql'
PageInfo is provided by this package, not from @nestjs/graphql.
ConnectionCursor
import { ConnectionCursor } from 'nestjs-graphql-relay'
import { ConnectionCursor } from 'graphql-relay'
Recommended to import from nestjs-graphql-relay for proper type compatibility.

Defines Relay-compatible edge and connection types using the package's decorators.

import { ObjectType, Field } from '@nestjs/graphql'; import { Relay, PageInfo } from 'nestjs-graphql-relay'; @ObjectType({ isAbstract: true }) abstract class RecipeEdge implements Relay.Edge<Recipe> { @Field(() => Recipe) node: Recipe; @Field() cursor: Relay.ConnectionCursor; } @ObjectType() export class RecipeConnection implements Relay.Connection<Recipe> { @Field() pageInfo: PageInfo; @Field(() => [RecipeEdge]) edges: Array<Relay.Edge<Recipe>>; }
Debug
Known issues
breakingVersion 11 requires @nestjs/graphql >=13.1.0 and graphql-relay ^0.10.2. Older versions are incompatible.
fix
Upgrade @nestjs/graphql to 13.1.0+ and graphql-relay to 0.10.2+.
affects: >=11.0.0
deprecatedIn older versions (<10), the import path was different. Direct imports from subpaths are deprecated.
fix
Use import { Relay } from 'nestjs-graphql-relay' instead of import * from 'nestjs-graphql-relay/dist/...'.
affects: <11.0.0
gotchaThe Relay namespace types (Edge, Connection) require generic type parameters. Forgetting them leads to TypeScript errors.
fix
Always specify the node type (e.g., Relay.Edge<Recipe>) to satisfy type constraints.
affects: >=11.0.0
gotchaTypeORM entities must be decorated with @ObjectType() for proper code generation. Missing it causes runtime errors.
fix
Ensure all entities used in connections have @ObjectType() decorator from @nestjs/graphql.
affects: >=11.0.0
Errors
Common errors & fixes
Cannot find module 'nestjs-graphql-relay' or its corresponding type declarations.
Package not installed or missing type definitions.
fix
Run 'npm install nestjs-graphql-relay'. Ensure tsconfig.json includes 'node_modules/@types'.
Type 'Relay.Edge<Recipe>' is not generic.
Importing Relay from wrong package (e.g., graphql-relay) instead of nestjs-graphql-relay.
fix
Use import { Relay } from 'nestjs-graphql-relay'.
Property 'pageInfo' does not exist on type 'RecipeConnection'.
Missing @Field() decorator on pageInfo or edges field.
fix
Add @Field() decorator to pageInfo and @Field(() => [RecipeEdge]) to edges.
Upgrade
Version history
11.0.2latest on npm
Audit
Dependencies
@nestjs/graphqlrequiredCore dependency for GraphQL integration in NestJS.
graphql-relayrequiredProvides Relay types and utilities.
typeormrequiredORM used for database interactions.
class-validatorrequiredUsed for validation decorators on input types.
Agent activity
7 hits · last 30 days
node
6
Amazon
1
Resources
nestjs-graphql-relay — npm install nestjs-graphql-relay · libregistry