Registry /
devops / nestjs-graphql-connection
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.
createEdgeType
✓ import { createEdgeType } from 'nestjs-graphql-connection'
✗ const createEdgeType = require('nestjs-graphql-connection').createEdgeType
ESM-only; named export.
createConnectionType
✓ import { createConnectionType } from 'nestjs-graphql-connection'
✗ import createConnectionType from 'nestjs-graphql-connection'
No default export. Use named import.
ConnectionArgs
✓ import { ConnectionArgs } from 'nestjs-graphql-connection'
✗ import { ConnectionArgs as Args } from 'nestjs-graphql-connection'
Class, not a type. Use as base class with extends.
ConnectionBuilder
✓ import { ConnectionBuilder } from 'nestjs-graphql-connection'
Generic abstract class. Must implement createConnection, createEdge, createCursor, decodeCursor.
Cursor
✓ import { Cursor } from 'nestjs-graphql-connection'
Class to create and decode cursors. Pass parameters in constructor.
Defines a PersonEdge, PersonConnection, ConnectionArgs subclass, and a ConnectionBuilder for Relay-style pagination.
// person.edge.ts
import { ObjectType } from '@nestjs/graphql';
import { createEdgeType } from 'nestjs-graphql-connection';
import { Person } from './person.entity';
@ObjectType()
export class PersonEdge extends createEdgeType(Person) {}
// person.connection.ts
import { ObjectType } from '@nestjs/graphql';
import { createConnectionType } from 'nestjs-graphql-connection';
import { PersonEdge } from './person.edge';
@ObjectType()
export class PersonConnection extends createConnectionType(PersonEdge) {}
// person.args.ts
import { ArgsType, Field, ID } from '@nestjs/graphql';
import { ConnectionArgs } from 'nestjs-graphql-connection';
@ArgsType()
export class PersonConnectionArgs extends ConnectionArgs {
@Field(type => ID, { nullable: true })
public personId?: string;
}
// person.builder.ts
import {
ConnectionBuilder,
Cursor,
EdgeInputWithCursor,
PageInfo,
} from 'nestjs-graphql-connection';
import { PersonConnection } from './person.connection';
import { PersonConnectionArgs } from './person.args';
import { PersonEdge } from './person.edge';
import { Person } from './person.entity';
export type PersonCursorParams = { id: string };
export type PersonCursor = Cursor<PersonCursorParams>;
export class PersonConnectionBuilder extends ConnectionBuilder<
PersonConnection,
PersonConnectionArgs,
PersonEdge,
Person,
PersonCursor
> {
public createConnection(fields: { edges: PersonEdge[]; pageInfo: PageInfo }): PersonConnection {
return new PersonConnection(fields);
}
public createEdge(fields: EdgeInputWithCursor<PersonEdge>): PersonEdge {
return new PersonEdge(fields);
}
public createCursor(node: Person): PersonCursor {
return new Cursor({ id: node.id });
}
public decodeCursor(encodedString: string): PersonCursor {
const decoded = Buffer.from(encodedString, 'base64').toString('utf-8');
const params: PersonCursorParams = JSON.parse(decoded);
return new Cursor(params);
}
}
Errors
Common errors & fixes
Cannot find module 'nestjs-graphql-connection'
Package not installed or typo in import path
fixRun 'npm install nestjs-graphql-connection' and ensure import is from 'nestjs-graphql-connection' (no subpath).
TypeError: Class extends value undefined is not a constructor or null
createEdgeType or createConnectionType called with a class that is not a GraphQL ObjectType
fixEnsure the argument to createEdgeType is a class decorated with @ObjectType().
Cannot read properties of undefined (reading 'prototype')
Incorrect usage: calling createEdgeType without 'new' when extending
fixUse 'extends createEdgeType(Person)' not 'extends new createEdgeType(Person)'.
Audit
Dependencies
@nestjs/commonrequiredRequired to use NestJS decorators and base classes
@nestjs/corerequiredRequired for NestJS module system
@nestjs/graphqlrequiredRequired for GraphQL integration (ObjectType, ArgsType, etc.)
reflect-metadatarequiredRequired by NestJS for decorator metadata