Functions

@system-inc/base-foundation · 515c140 · 11 symbols

Builds the Pagination a paginated result carries.

ormPaginatedFind covers every read that is a find over an entity, which is nearly all of them. A handful of resolvers cannot use it - a GROUP BY has no entity to find, and a hand-written join may not map to one - and those have to assemble this object themselves. Doing that by hand is how the shape drifts: one existing resolver computes a zero-based page where the find layer computes it one-based, and none of them populate the next/previous cursors at all, so a client cannot tell those results apart from a single-page one.

So the arithmetic lives here and both paths call it. A resolver still runs its own LIMIT/OFFSET and its own COUNT; it just does not get to invent what the numbers around them mean.

buildPagination(input: { itemIndex: number; itemsPerPage: number; itemsReturned: number; itemsTotal: number }): Pagination

View source ↗

Claims a generated name prefix for a declaration. Called last by @PaginationInputFor, so only a declaration that fully succeeded owns its generated names.

claimPaginationInputBaseName(baseName: string, inputClass: Constructor<object>): void

View source ↗

All declared pagination inputs — consumed by base check tooling.

getAllPaginationInputMetadata(): ReadonlyMap<Constructor<object>, PaginationInputMetadata>

View source ↗

The class currently owning a generated name prefix, or undefined if the prefix is unclaimed.

getPaginationInputBaseNameOwner(baseName: string): Constructor<object> | undefined

View source ↗

Resolve the declared pagination metadata for an input class, walking the prototype chain so a subclass of a declared input inherits its contract.

getPaginationInputMetadata(inputClass: Constructor<object>): PaginationInputMetadata | undefined

View source ↗

Build a GraphQL schema from a GqlConfiguration.

Shared primitive for any GqlServerProvider that uses type-graphql. Lives at the foundation level (not inside a specific provider) so other providers — Apollo, Mercurius, etc. — can reuse the same DI/validation/ middleware wiring.

gqlBuildSchema(config: GqlConfiguration): Promise<GraphQLSchema>

View source ↗

gqlMaskError

function
gqlMaskError(error: unknown, defaultErrorMessage: string): Error

View source ↗

The context-bag key a resolver's GqlOperationContext is stored under, derived from the field's response path so it is unique per field invocation.

Keying by the resolver method (Class.method) would collide when a document aliases the same field twice — a: user{name} b: user{email} — making both invocations read the last one's selection set. The response path (a, b, parent.child, …) is unique per field. Namespaced so a field aliased operations/request can't clobber a real GqlContext property.

gqlOperationContextKey(info: GraphQLResolveInfo): string

View source ↗

orderByDirectionToSql(direction?: OrderByDirection): SqlOrderByDirection

View source ↗

orderByInputToFindOptionsOrder(orderBy: OrderByInput | OrderByInput[]): OrmFindOptionsOrder<object>

View source ↗

Records what a declaration resolved to. Called by @PaginationInputFor once the declaration has been fully validated.

recordPaginationInputMetadata(inputClass: Constructor<object>, metadata: PaginationInputMetadata): void

View source ↗