import { merge } from 'lodash'; import { Arg, Query, Resolver } from 'type-graphql'; import { AggregateProductVariant } from '@/entities'; import { AggregateProductVariantInput, AggregateProductVariantPayload, DEFAULT_AGGREGATE_PRODUCT_INPUT, } from './types'; @Resolver(AggregateProductVariant) export class AggregateProductVariantResolver { @Query(() => AggregateProductVariantPayload, { nullable: false, description: `Aggregate product.`, }) async aggregateProductVariant( @Arg('input', { nullable: false }) inputWithoutDefaults: AggregateProductVariantInput ): Promise { const input = merge( {}, DEFAULT_AGGREGATE_PRODUCT_INPUT, inputWithoutDefaults ); const aggregateProductVariant = await AggregateProductVariant.findOneOrFail( input.id ); return { aggregateProductVariant, }; } }