Skip to main content

@nest-boot/graphql-connection

Enumerations

OrderDirection

Defined in: packages/graphql-connection/src/enums/order-direction.enum.ts:14

Specifies the direction for ordering query results.

Example

const order = {
field: "CREATED_AT",
direction: OrderDirection.DESC,
};

Enumeration Members

ASC
ASC: "ASC";

Defined in: packages/graphql-connection/src/enums/order-direction.enum.ts:18

Ascending order (smallest to largest, A to Z, oldest to newest).

DESC
DESC: "DESC";

Defined in: packages/graphql-connection/src/enums/order-direction.enum.ts:23

Descending order (largest to smallest, Z to A, newest to oldest).

Classes

ConnectionBuilder

Defined in: packages/graphql-connection/src/connection.builder.ts:97

Builder class for creating GraphQL connection types following the Relay specification.

The ConnectionBuilder generates all necessary GraphQL types for cursor-based pagination:

  • Connection type with edges, pageInfo, and totalCount
  • Edge type with node and cursor
  • ConnectionArgs type with first, last, after, before, orderBy, filter, and query
  • Order input type for sorting
  • Filter scalar type for MongoDB-style filtering

Examples

import { ConnectionBuilder } from "@nest-boot/graphql-connection";
import { User } from "./user.entity";

const { Connection, ConnectionArgs, Edge } = new ConnectionBuilder(User)
.addField({ field: "name", type: "string", filterable: true, sortable: true })
.addField({ field: "createdAt", type: "date", sortable: true })
.build();

// Use in resolver
@Query(() => Connection)
async users(@Args() args: typeof ConnectionArgs) {
return this.connectionManager.find(Connection, args);
}
const { Connection, ConnectionArgs } = new ConnectionBuilder(User, {
filter: {
maxDepth: 3,
maxConditions: 10,
},
})
.addField({ field: "email", type: "string", filterable: true })
.build();

Type Parameters

Type ParameterDescription
Entity extends objectThe MikroORM entity type for the connection

Constructors

Constructor
new ConnectionBuilder<Entity>(entityClass, options?): ConnectionBuilder<Entity>;

Defined in: packages/graphql-connection/src/connection.builder.ts:113

Creates a new ConnectionBuilder instance.

Parameters
ParameterTypeDescription
entityClassEntityClass<Entity>The MikroORM entity class to build connection types for
options?Partial<ConnectionBuilderOptions>Optional configuration for the connection builder
Returns

ConnectionBuilder<Entity>

Methods

addField()
addField<Type, Field>(options): this;

Defined in: packages/graphql-connection/src/connection.builder.ts:151

Adds a field configuration to the connection builder.

Fields can be configured for filtering, sorting, and searching. The field type determines what filter operators are available.

Type Parameters
Type ParameterDescription
Type extends "string" | "number" | "boolean" | "date"The field type ("string", "number", "boolean", or "date")
Field extends stringThe field path in the entity
Parameters
ParameterTypeDescription
optionsFieldOptions<Entity, Type, Field>The field configuration options
Returns

this

The builder instance for method chaining

Example
builder
.addField({ field: "name", type: "string", filterable: true, searchable: true })
.addField({ field: "age", type: "number", filterable: true, sortable: true })
.addField({ field: "isActive", type: "boolean", filterable: true })
.addField({ field: "createdAt", type: "date", sortable: true });
build()
build(): ConnectionBuildResult<Entity>;

Defined in: packages/graphql-connection/src/connection.builder.ts:170

Builds and returns all GraphQL types for the connection.

The returned object contains both generic type references and entity-specific named types (e.g., UserConnection, UserEdge).

Returns

ConnectionBuildResult<Entity>

An object containing all generated connection types


ConnectionManager

Defined in: packages/graphql-connection/src/connection.manager.ts:66

Service for executing paginated GraphQL connection queries.

The ConnectionManager provides a high-level API for querying entities with cursor-based pagination following the Relay connection specification.

Examples

@Resolver(() => User)
export class UserResolver {
constructor(private readonly connectionManager: ConnectionManager) {}

@Query(() => UserConnection)
async users(@Args() args: UserConnectionArgs): Promise<UserConnection> {
return this.connectionManager.find(UserConnection, args);
}
}
@Query(() => UserConnection)
async activeUsers(@Args() args: UserConnectionArgs): Promise<UserConnection> {
return this.connectionManager.find(UserConnection, args, {
where: { isActive: true },
});
}

Constructors

Constructor
new ConnectionManager(em): ConnectionManager;

Defined in: packages/graphql-connection/src/connection.manager.ts:67

Parameters
ParameterType
emEntityManager
Returns

ConnectionManager

Methods

find()
find<Entity, Hint, Fields, Excludes>(
connectionClass,
args,
options?): Promise<ConnectionInterface<Entity>>;

Defined in: packages/graphql-connection/src/connection.manager.ts:81

Finds entities and returns them as a paginated connection.

Type Parameters
Type ParameterDescription
Entity extends objectThe entity type being queried
Hint extends stringType hints for population
Fields extends stringFields to select
Excludes extends stringFields to exclude
Parameters
ParameterTypeDescription
connectionClassConnectionClass<Entity>The connection class generated by ConnectionBuilder
argsConnectionArgsInterface<Entity>The connection arguments (first, last, after, before, orderBy, filter, query)
options?ConnectionFindOptions<Entity, Hint, Fields, Excludes>Additional find options (where, populate, etc.)
Returns

Promise<ConnectionInterface<Entity>>

A promise that resolves to the paginated connection result


GraphQLConnectionModule

Defined in: packages/graphql-connection/src/graphql-connection.module.ts:31

NestJS module that provides GraphQL connection-based pagination functionality.

This module is global and provides the ConnectionManager service for executing paginated queries following the Relay connection specification.

Example

import { Module } from "@nestjs/common";
import { GraphQLConnectionModule } from "@nest-boot/graphql-connection";

@Module({
imports: [GraphQLConnectionModule.register()],
})
export class AppModule {}

See

Extends

  • ConfigurableModuleClass

Indexable

[key: string]: any

Constructors

Constructor
new GraphQLConnectionModule(): GraphQLConnectionModule;

Defined in: node_modules/.pnpm/@nestjs+common@11.1.9/node_modules/@nestjs/common/module-utils/interfaces/configurable-module-cls.interface.d.ts:12

Returns

GraphQLConnectionModule

Inherited from
ConfigurableModuleClass.constructor

Properties

register()
static register: (options) => DynamicModule;
Parameters
ParameterType
optionsPartial<{ }>
Returns

DynamicModule

Inherited from
ConfigurableModuleClass.register
registerAsync()
static registerAsync: (options) => DynamicModule;
Parameters
ParameterType
optionsConfigurableModuleAsyncOptions<unknown, "create"> & Partial<{ }>
Returns

DynamicModule

Inherited from
ConfigurableModuleClass.registerAsync

PageInfo

Defined in: packages/graphql-connection/src/objects/page-info.object.ts:27

Provides information about pagination in a connection.

PageInfo is used to determine whether more pages exist and to fetch additional pages using cursor-based pagination.

See

Relay PageInfo Specification

Example

const result = await connectionManager.find(UserConnection, { first: 10 });

if (result.pageInfo.hasNextPage) {
// Fetch next page using endCursor
const nextPage = await connectionManager.find(UserConnection, {
first: 10,
after: result.pageInfo.endCursor,
});
}

Constructors

Constructor
new PageInfo(): PageInfo;
Returns

PageInfo

Properties

endCursor
endCursor: string | null;

Defined in: packages/graphql-connection/src/objects/page-info.object.ts:58

The cursor of the last edge in the current page. Can be used with after for forward pagination.

hasNextPage
hasNextPage: boolean;

Defined in: packages/graphql-connection/src/objects/page-info.object.ts:35

Whether there are more pages to fetch following the current page.

hasPreviousPage
hasPreviousPage: boolean;

Defined in: packages/graphql-connection/src/objects/page-info.object.ts:44

Whether there are any pages prior to the current page.

startCursor
startCursor: string | null;

Defined in: packages/graphql-connection/src/objects/page-info.object.ts:51

The cursor of the first edge in the current page. Can be used with before for backward pagination.

Interfaces

BaseFieldOptions

Defined in: packages/graphql-connection/src/types/field-options.type.ts:11

Base options shared by all field types.

Properties

filterable?
optional filterable: boolean;

Defined in: packages/graphql-connection/src/types/field-options.type.ts:16

Whether this field can be used in filter queries.

Default
true
searchable?
optional searchable: boolean;

Defined in: packages/graphql-connection/src/types/field-options.type.ts:22

Whether this field is included in text search queries. Only applicable to string fields.


ConnectionArgsInterface

Defined in: packages/graphql-connection/src/interfaces/connection-args.interface.ts:30

Arguments for querying a paginated connection.

Supports both forward pagination (first/after) and backward pagination (last/before), as well as filtering, ordering, and search query functionality.

Examples

const args: ConnectionArgsInterface<User> = {
first: 10,
after: "cursor123",
orderBy: { field: "CREATED_AT", direction: OrderDirection.DESC },
};
const args: ConnectionArgsInterface<User> = {
last: 10,
before: "cursor456",
};

Type Parameters

Type ParameterDescription
Entity extends objectThe entity type being queried

Properties

after?
optional after: string;

Defined in: packages/graphql-connection/src/interfaces/connection-args.interface.ts:34

Returns elements after this cursor (for forward pagination).

before?
optional before: string;

Defined in: packages/graphql-connection/src/interfaces/connection-args.interface.ts:39

Returns elements before this cursor (for backward pagination).

filter?
optional filter: FilterQuery<Entity>;

Defined in: packages/graphql-connection/src/interfaces/connection-args.interface.ts:60

A MongoDB-style filter query to apply to the results.

first?
optional first: number;

Defined in: packages/graphql-connection/src/interfaces/connection-args.interface.ts:44

Returns up to the first n elements (for forward pagination).

last?
optional last: number;

Defined in: packages/graphql-connection/src/interfaces/connection-args.interface.ts:49

Returns up to the last n elements (for backward pagination).

orderBy?
optional orderBy: OrderInterface<Entity>;

Defined in: packages/graphql-connection/src/interfaces/connection-args.interface.ts:65

Ordering options for the returned results.

query?
optional query: string;

Defined in: packages/graphql-connection/src/interfaces/connection-args.interface.ts:55

A search query string to filter results. Parsed using search-syntax and applied to searchable fields.


ConnectionBuilderOptions

Defined in: packages/graphql-connection/src/interfaces/connection-builder-options.interface.ts:18

Configuration options for the ConnectionBuilder.

Example

const options: ConnectionBuilderOptions = {
filter: {
maxDepth: 3,
maxConditions: 10,
maxOrBranches: 3,
maxArrayLength: 50,
},
};

Properties

filter?
optional filter: FilterOptions;

Defined in: packages/graphql-connection/src/interfaces/connection-builder-options.interface.ts:23

Options for the filter query schema builder. Controls limits on filter complexity to prevent abuse.


ConnectionFindOptions

Defined in: packages/graphql-connection/src/connection.manager.ts:20

Options for the ConnectionManager.find method.

Extends MikroORM FindOptions but excludes pagination-related options (limit, offset, orderBy) which are handled by the connection arguments.

Extends

  • Exclude<FindOptions<Entity, Hint, Fields, Excludes>, "limit" | "offset" | "orderBy">

Type Parameters

Type ParameterDescription
Entity extends objectThe entity type being queried
Hint extends stringType hints for population
Fields extends stringFields to select
Excludes extends stringFields to exclude

Properties

after?
optional after: 
| string
| FilterObject<Entity>
| {
endCursor: string | null;
};

Defined in: node_modules/.pnpm/@mikro-orm+core@6.6.2/node_modules/@mikro-orm/core/drivers/IDatabaseDriver.d.ts:114

Fetch items after this cursor.

Inherited from
Exclude.after
before?
optional before: 
| string
| FilterObject<Entity>
| {
startCursor: string | null;
};

Defined in: node_modules/.pnpm/@mikro-orm+core@6.6.2/node_modules/@mikro-orm/core/drivers/IDatabaseDriver.d.ts:110

Fetch items before this cursor.

Inherited from
Exclude.before
cache?
optional cache: number | boolean | [string, number];

Defined in: node_modules/.pnpm/@mikro-orm+core@6.6.2/node_modules/@mikro-orm/core/drivers/IDatabaseDriver.d.ts:96

Control result caching for this query. Result cache is by default disabled, not to be confused with the identity map.

Inherited from
Exclude.cache
comments?
optional comments: string | string[];

Defined in: node_modules/.pnpm/@mikro-orm+core@6.6.2/node_modules/@mikro-orm/core/drivers/IDatabaseDriver.d.ts:144

sql only

Inherited from
Exclude.comments
connectionType?
optional connectionType: ConnectionType;

Defined in: node_modules/.pnpm/@mikro-orm+core@6.6.2/node_modules/@mikro-orm/core/drivers/IDatabaseDriver.d.ts:140

Inherited from
Exclude.connectionType
convertCustomTypes?
optional convertCustomTypes: boolean;

Defined in: node_modules/.pnpm/@mikro-orm+core@6.6.2/node_modules/@mikro-orm/core/drivers/IDatabaseDriver.d.ts:124

Inherited from
Exclude.convertCustomTypes
ctx?
optional ctx: any;

Defined in: node_modules/.pnpm/@mikro-orm+core@6.6.2/node_modules/@mikro-orm/core/drivers/IDatabaseDriver.d.ts:139

Inherited from
Exclude.ctx
disableIdentityMap?
optional disableIdentityMap: boolean;

Defined in: node_modules/.pnpm/@mikro-orm+core@6.6.2/node_modules/@mikro-orm/core/drivers/IDatabaseDriver.d.ts:125

Inherited from
Exclude.disableIdentityMap
exclude?
optional exclude: readonly AutoPath<Entity, Excludes, never, 9>[];

Defined in: node_modules/.pnpm/@mikro-orm+core@6.6.2/node_modules/@mikro-orm/core/drivers/IDatabaseDriver.d.ts:75

Inherited from
Exclude.exclude
fields?
optional fields: readonly AutoPath<Entity, Fields, "*", 9>[];

Defined in: node_modules/.pnpm/@mikro-orm+core@6.6.2/node_modules/@mikro-orm/core/drivers/IDatabaseDriver.d.ts:74

Inherited from
Exclude.fields
filters?
optional filters: FilterOptions;

Defined in: node_modules/.pnpm/@mikro-orm+core@6.6.2/node_modules/@mikro-orm/core/drivers/IDatabaseDriver.d.ts:134

Inherited from
Exclude.filters
first?
optional first: number;

Defined in: node_modules/.pnpm/@mikro-orm+core@6.6.2/node_modules/@mikro-orm/core/drivers/IDatabaseDriver.d.ts:118

Fetch first N items.

Inherited from
Exclude.first
flags?
optional flags: QueryFlag[];

Defined in: node_modules/.pnpm/@mikro-orm+core@6.6.2/node_modules/@mikro-orm/core/drivers/IDatabaseDriver.d.ts:127

Inherited from
Exclude.flags
flushMode?
optional flushMode: FlushMode | "commit" | "auto" | "always";

Defined in: node_modules/.pnpm/@mikro-orm+core@6.6.2/node_modules/@mikro-orm/core/drivers/IDatabaseDriver.d.ts:133

Inherited from
Exclude.flushMode
groupBy?
optional groupBy: string | string[];

Defined in: node_modules/.pnpm/@mikro-orm+core@6.6.2/node_modules/@mikro-orm/core/drivers/IDatabaseDriver.d.ts:129

sql only

Inherited from
Exclude.groupBy
having?
optional having: QBFilterQuery<Entity>;

Defined in: node_modules/.pnpm/@mikro-orm+core@6.6.2/node_modules/@mikro-orm/core/drivers/IDatabaseDriver.d.ts:130

Inherited from
Exclude.having
hintComments?
optional hintComments: string | string[];

Defined in: node_modules/.pnpm/@mikro-orm+core@6.6.2/node_modules/@mikro-orm/core/drivers/IDatabaseDriver.d.ts:146

sql only

Inherited from
Exclude.hintComments
indexHint?
optional indexHint: string;

Defined in: node_modules/.pnpm/@mikro-orm+core@6.6.2/node_modules/@mikro-orm/core/drivers/IDatabaseDriver.d.ts:142

sql only

Inherited from
Exclude.indexHint
last?
optional last: number;

Defined in: node_modules/.pnpm/@mikro-orm+core@6.6.2/node_modules/@mikro-orm/core/drivers/IDatabaseDriver.d.ts:120

Fetch last N items.

Inherited from
Exclude.last
limit?
optional limit: number;

Defined in: node_modules/.pnpm/@mikro-orm+core@6.6.2/node_modules/@mikro-orm/core/drivers/IDatabaseDriver.d.ts:102

Limit the number of returned results. If you try to use limit/offset on a query that joins a to-many relation, pagination mechanism will be triggered, resulting in a subquery condition, to apply this limit only to the root entities instead of the cartesian product you get from a database in this case.

Inherited from
Exclude.limit
lockMode?
optional lockMode: 
| NONE
| PESSIMISTIC_READ
| PESSIMISTIC_WRITE
| PESSIMISTIC_PARTIAL_WRITE
| PESSIMISTIC_WRITE_OR_FAIL
| PESSIMISTIC_PARTIAL_READ
| PESSIMISTIC_READ_OR_FAIL;

Defined in: node_modules/.pnpm/@mikro-orm+core@6.6.2/node_modules/@mikro-orm/core/drivers/IDatabaseDriver.d.ts:136

sql only

Inherited from
Exclude.lockMode
lockTableAliases?
optional lockTableAliases: string[];

Defined in: node_modules/.pnpm/@mikro-orm+core@6.6.2/node_modules/@mikro-orm/core/drivers/IDatabaseDriver.d.ts:138

sql only

Inherited from
Exclude.lockTableAliases
loggerContext?
optional loggerContext: LogContext;

Defined in: node_modules/.pnpm/@mikro-orm+core@6.6.2/node_modules/@mikro-orm/core/drivers/IDatabaseDriver.d.ts:147

Inherited from
Exclude.loggerContext
logging?
optional logging: LoggingOptions;

Defined in: node_modules/.pnpm/@mikro-orm+core@6.6.2/node_modules/@mikro-orm/core/drivers/IDatabaseDriver.d.ts:148

Inherited from
Exclude.logging
offset?
optional offset: number;

Defined in: node_modules/.pnpm/@mikro-orm+core@6.6.2/node_modules/@mikro-orm/core/drivers/IDatabaseDriver.d.ts:108

Sets the offset. If you try to use limit/offset on a query that joins a to-many relation, pagination mechanism will be triggered, resulting in a subquery condition, to apply this limit only to the root entities instead of the cartesian product you get from a database in this case.

Inherited from
Exclude.offset
orderBy?
optional orderBy: OrderDefinition<Entity>;

Defined in: node_modules/.pnpm/@mikro-orm+core@6.6.2/node_modules/@mikro-orm/core/drivers/IDatabaseDriver.d.ts:94

Ordering of the results.Can be an object or array of objects, keys are property names, values are ordering (asc/desc)

Inherited from
Exclude.orderBy
overfetch?
optional overfetch: boolean;

Defined in: node_modules/.pnpm/@mikro-orm+core@6.6.2/node_modules/@mikro-orm/core/drivers/IDatabaseDriver.d.ts:122

Fetch one more item than first/last, enabled automatically in em.findByCursor to check if there is a next page.

Inherited from
Exclude.overfetch
populate?
optional populate: Populate<Entity, Hint>;

Defined in: node_modules/.pnpm/@mikro-orm+core@6.6.2/node_modules/@mikro-orm/core/drivers/IDatabaseDriver.d.ts:73

Inherited from
Exclude.populate
populateFilter?
optional populateFilter: ObjectQuery<Entity>;

Defined in: node_modules/.pnpm/@mikro-orm+core@6.6.2/node_modules/@mikro-orm/core/drivers/IDatabaseDriver.d.ts:90

Filter condition for populated relations. This is similar to populateWhere, but will produce a left join when nesting the condition. This is used for implementation of joined filters.

Inherited from
Exclude.populateFilter
populateOrderBy?
optional populateOrderBy: OrderDefinition<Entity>;

Defined in: node_modules/.pnpm/@mikro-orm+core@6.6.2/node_modules/@mikro-orm/core/drivers/IDatabaseDriver.d.ts:92

Used for ordering of the populate queries. If not specified, the value of options.orderBy is used.

Inherited from
Exclude.populateOrderBy
populateWhere?
optional populateWhere: ObjectQuery<Entity> | PopulateHint | "infer" | "all";

Defined in: node_modules/.pnpm/@mikro-orm+core@6.6.2/node_modules/@mikro-orm/core/drivers/IDatabaseDriver.d.ts:85

Where condition for populated relations. This will have no effect on the root entity. With select-in strategy, this is applied only to the populate queries. With joined strategy, those are applied as join on conditions. When you use a nested condition on a to-many relation, it will produce a nested inner join, discarding the collection items based on the child condition.

Inherited from
Exclude.populateWhere
refresh?
optional refresh: boolean;

Defined in: node_modules/.pnpm/@mikro-orm+core@6.6.2/node_modules/@mikro-orm/core/drivers/IDatabaseDriver.d.ts:123

Inherited from
Exclude.refresh
schema?
optional schema: string;

Defined in: node_modules/.pnpm/@mikro-orm+core@6.6.2/node_modules/@mikro-orm/core/drivers/IDatabaseDriver.d.ts:126

Inherited from
Exclude.schema
strategy?
optional strategy: LoadStrategy | "select-in" | "joined" | "balanced";

Defined in: node_modules/.pnpm/@mikro-orm+core@6.6.2/node_modules/@mikro-orm/core/drivers/IDatabaseDriver.d.ts:132

sql only

Inherited from
Exclude.strategy
where?
optional where: FilterQuery<Entity>;

Defined in: packages/graphql-connection/src/connection.manager.ts:33

Additional filter query to apply to the connection query. This is merged with any filters from the connection arguments.


ConnectionInterface

Defined in: packages/graphql-connection/src/interfaces/connection.interface.ts:14

Represents a paginated connection following the Relay specification.

A connection contains a list of edges (items with cursors), pagination info, and the total count of items matching the query.

See

Relay Connection Specification

Type Parameters

Type ParameterDescription
TThe type of entities in the connection

Properties

edges
edges: EdgeInterface<T>[];

Defined in: packages/graphql-connection/src/interfaces/connection.interface.ts:18

A list of edges, each containing a node and its cursor.

pageInfo
pageInfo: PageInfo;

Defined in: packages/graphql-connection/src/interfaces/connection.interface.ts:23

Information about the current page for pagination.

totalCount
totalCount: number;

Defined in: packages/graphql-connection/src/interfaces/connection.interface.ts:28

The total number of items matching the query (before pagination).


CreateFilterResult

Defined in: packages/graphql-connection/src/utils/create-filter.ts:64

The result of creating a filter scalar and schema.

Type Parameters

Type ParameterDescription
Entity extends objectThe entity type for the filter

Properties

Filter
Filter: GraphQLScalarType<FilterQuery<Entity>>;

Defined in: packages/graphql-connection/src/utils/create-filter.ts:68

The GraphQL scalar type for the filter.

filterQuerySchema
filterQuerySchema: ZodType<FilterQuery<Entity>>;

Defined in: packages/graphql-connection/src/utils/create-filter.ts:73

The Zod schema for validating filter queries.


CreateOrderResult

Defined in: packages/graphql-connection/src/utils/create-order.ts:20

The result of creating order types.

Type Parameters

Type ParameterDescription
Entity extends objectThe entity type for ordering

Properties

Order
Order: Type<OrderInterface<Entity>>;

Defined in: packages/graphql-connection/src/utils/create-order.ts:24

The Order input type class.

OrderField
OrderField: OrderFieldType<Entity>;

Defined in: packages/graphql-connection/src/utils/create-order.ts:29

The OrderField enum object mapping field keys to paths.


EdgeInterface

Defined in: packages/graphql-connection/src/interfaces/edge.interface.ts:11

Represents an edge in a GraphQL connection.

An edge contains a single item (node) and a cursor that can be used for pagination to fetch items before or after this position.

See

Relay Edge Type Specification

Type Parameters

Type ParameterDescription
TThe type of the node (entity) in the edge

Properties

cursor
cursor: string;

Defined in: packages/graphql-connection/src/interfaces/edge.interface.ts:21

A cursor for use in pagination. Can be passed to after or before arguments.

node
node: T;

Defined in: packages/graphql-connection/src/interfaces/edge.interface.ts:15

The item at the end of this edge.


OrderInterface

Defined in: packages/graphql-connection/src/interfaces/order.interface.ts:17

Specifies the ordering for a connection query.

Example

const order: OrderInterface<User> = {
field: "CREATED_AT",
direction: OrderDirection.DESC,
};

Type Parameters

Type ParameterDescription
TThe entity type being ordered

Properties

direction
direction: OrderDirection;

Defined in: packages/graphql-connection/src/interfaces/order.interface.ts:26

The direction to order (ASC or DESC).

field
field: Uppercase<DotToUnderscore<string extends StringKeys<T, never> ? `${StringKeys<T, never> & string}.${"" extends StringKeys<NonNullable<GetStringKey<T, StringKeys<T, never> & string, never>>, never> ? (NonNullable<GetStringKey<NonNullable<GetStringKey<(...), (...), (...)>>, StringKeys<(...), (...)> & "", never>> extends unknown ? "" : never) | (StringKeys<NonNullable<GetStringKey<NonNullable<(...)>, (...) & (...), never>>, never> extends never ? never : `${StringKeys<NonNullable<(...)>, never> & ""}.`) : StringKeys<NonNullable<GetStringKey<T, StringKeys<(...), (...)> & string, never>>, never> | `${CollectionKeys<NonNullable<GetStringKey<T, (...) & (...), never>>>}:ref`}` : never>>;

Defined in: packages/graphql-connection/src/interfaces/order.interface.ts:21

The field to order by (uppercase with underscores, e.g., "CREATED_AT").


SortableFieldOptions

Defined in: packages/graphql-connection/src/types/field-options.type.ts:28

Options for fields that can be sorted.

Properties

sortable?
optional sortable: boolean;

Defined in: packages/graphql-connection/src/types/field-options.type.ts:33

Whether this field can be used for ordering results. When true, the field will be included in the OrderField enum.

Type Aliases

FieldOptions

type FieldOptions<Entity, Type, Field> = 
| SimpleFieldOptions<Entity, Type>
| ReplacementFieldOptions<Entity, Type, Field>
| ReplacementFunctionFieldOptions<Entity, Type>;

Defined in: packages/graphql-connection/src/types/field-options.type.ts:110

Union type of all field option types.

This is the type used when adding fields to a ConnectionBuilder.

Type Parameters

Type ParameterDescription
Entity extends objectThe entity type
Type extends FieldTypeThe field type
Field extends stringThe GraphQL field name (for replacement options)

Examples

const options: FieldOptions<User, "string"> = {
field: "name",
type: "string",
filterable: true,
sortable: true,
};
const options: FieldOptions<User, "string", "authorName"> = {
field: "authorName",
type: "string",
replacement: "author.name",
filterable: true,
};

FilterQuerySchema

type FilterQuerySchema<Entity> = ReturnType<FilterQuerySchemaBuilder<Entity>["build"]>;

Defined in: packages/graphql-connection/src/utils/create-filter.ts:17

The Zod schema type returned by FilterQuerySchemaBuilder.

Type Parameters

Type ParameterDescription
Entity extends objectThe entity type for the filter

OrderFieldKey

type OrderFieldKey<T> = Uppercase<DotToUnderscore<AutoPath<T, string>>>;

Defined in: packages/graphql-connection/src/interfaces/order-field.type.ts:21

The key type for order fields.

Converts entity field paths to uppercase with underscores. For example, "createdAt" becomes "CREATED_AT", and "user.name" becomes "USER_NAME".

Type Parameters

Type ParameterDescription
TThe entity type

OrderFieldType

type OrderFieldType<T> = Record<OrderFieldKey<T>, OrderFieldValue<T>>;

Defined in: packages/graphql-connection/src/interfaces/order-field.type.ts:37

A record mapping order field keys to their actual field paths.

Used to create the GraphQL enum for sortable fields.

Type Parameters

Type ParameterDescription
TThe entity type

OrderFieldValue

type OrderFieldValue<T> = AutoPath<T, string>;

Defined in: packages/graphql-connection/src/interfaces/order-field.type.ts:28

The value type for order fields (the actual field path in the entity).

Type Parameters

Type ParameterDescription
TThe entity type

ReplacementFieldOptions

type ReplacementFieldOptions<Entity, Type, Field> = FilterReplacementFieldOptions<Entity, Type, Field> & BaseFieldOptions & SortableFieldOptions;

Defined in: packages/graphql-connection/src/types/field-options.type.ts:58

Options for a field with a replacement property path.

Use this when the GraphQL field name differs from the entity property path.

Type Parameters

Type ParameterDescription
Entity extends objectThe entity type
Type extends FieldTypeThe field type
Field extends stringThe GraphQL field name

ReplacementFunctionFieldOptions

type ReplacementFunctionFieldOptions<Entity, Type> = FilterReplacementCallbackFieldOptions<Entity, Type> & BaseFieldOptions & SortableFieldOptions;

Defined in: packages/graphql-connection/src/types/field-options.type.ts:74

Options for a field with a replacement callback function.

Use this for complex field mappings that require runtime logic.

Type Parameters

Type ParameterDescription
Entity extends objectThe entity type
Type extends FieldTypeThe field type

SimpleFieldOptions

type SimpleFieldOptions<Entity, Type> = FilterSimpleFieldOptions<Entity, Type> & BaseFieldOptions & SortableFieldOptions;

Defined in: packages/graphql-connection/src/types/field-options.type.ts:42

Options for a simple field with direct entity property mapping.

Type Parameters

Type ParameterDescription
Entity extends objectThe entity type
Type extends FieldTypeThe field type ("string", "number", "boolean", or "date")