fix(server): default page owner (#10015)

This commit is contained in:
forehalo
2025-02-07 07:31:56 +00:00
parent 9fd547d484
commit 4b1c931503
7 changed files with 97 additions and 36 deletions

View File

@@ -39,15 +39,16 @@ export class PaginationInput {
'returns the elements in the list that come after the specified cursor.',
middleware: [parseCursorMiddleware],
})
after!: string | null;
after?: string | null;
@Field(() => String, {
nullable: true,
description:
'returns the elements in the list that come before the specified cursor.',
middleware: [parseCursorMiddleware],
})
before!: string | null;
// NOT IMPLEMENTED YET
// @Field(() => String, {
// nullable: true,
// description:
// 'returns the elements in the list that come before the specified cursor.',
// middleware: [parseCursorMiddleware],
// })
// before?: string | null;
}
const encode = (input: string) => Buffer.from(input).toString('base64');

View File

@@ -1,17 +1,23 @@
import { Type } from '@nestjs/common';
import { Field, ObjectType } from '@nestjs/graphql';
import { Field, FieldOptions, ObjectType } from '@nestjs/graphql';
import { ApplyType } from '../utils/types';
export function registerObjectType<T>(
fields: Record<string, Type<any>>,
fields: Record<
string,
{
type: () => Type<any>;
options?: FieldOptions;
}
>,
options: {
name: string;
}
) {
const Inner = ApplyType<T>();
for (const [key, value] of Object.entries(fields)) {
Field(() => value)(Inner.prototype, key);
for (const [key, { type, options }] of Object.entries(fields)) {
Field(type, options)(Inner.prototype, key);
}
ObjectType(options.name)(Inner);