import { Field, InputType, ObjectType, registerEnumType } from 'type-graphql'; import { Page } from '@/entities'; import { OrderByDirection } from '@/types'; import { createOrderByType } from '@/utils/orderby'; import { createConnectionType } from '../shared/pagination'; @InputType({ description: 'Arguments for the page query.', }) export class PageInput { @Field(() => String, { nullable: true, description: 'The ID for the page being requested', }) id?: string; @Field(() => String, { nullable: true, description: 'The Firebase ID for the page being requested', }) firebaseId?: string; } export enum PagesOrderByField { FEATURED = 'FEATURED', } registerEnumType(PagesOrderByField, { name: 'ReportsOrderByField', }); @InputType() export class PagesOrderBy extends createOrderByType( 'Pages', PagesOrderByField ) {} export const PAGES_INPUT_DEFAULTS = { orderBy: { field: PagesOrderByField.FEATURED, direction: OrderByDirection.DESC, }, }; @InputType({ description: 'Arguments for the page query.', }) export class PagesInput { @Field(() => String, { nullable: true, description: 'The retailer this page is associated with.', }) retailer?: string; @Field(() => Boolean, { nullable: true, description: 'Whether or not the page has an image.', }) hasImage?: boolean; @Field(() => Boolean, { nullable: true, description: 'Whether or not the page has been marked as available', }) availability?: boolean; @Field(() => String, { description: 'The url of the pages.', nullable: true }) url?: string; @Field(() => PagesOrderBy, { nullable: true, defaultValue: PAGES_INPUT_DEFAULTS.orderBy, }) orderBy: PagesOrderBy = PAGES_INPUT_DEFAULTS.orderBy; } @ObjectType({ description: 'The connection type for Page.', }) export class PageConnection extends createConnectionType('Page', Page) {}