I’ve been using nestjs-query for a while, but I’m confused about how to expose and fetch relations when using custom endpoints. I could finds any guidance on the documentation. Could someone provide guidance on this.?
event.resolver.ts
import { InjectQueryService, QueryService } from '@nestjs-query/core';
import {
ArrayConnectionType,
CRUDResolver,
CursorConnectionType,
OffsetConnectionType,
Relation,
} from '@nestjs-query/query-graphql';
import {
HttpException,
HttpStatus,
Inject,
Logger,
UseGuards,
} from '@nestjs/common';
import { Args, Context, ID, Query, Resolver } from '@nestjs/graphql';
import { JwtService } from '@nestjs/jwt';
import { InjectRepository } from '@nestjs/typeorm';
import { OrganizationRole } from 'src/common/decorators';
import { EventEntity, OrganizationEntity } from 'src/common/entities';
import { EventDetailsType, EventType } from 'src/common/graphql';
import {
EventDetailsArgs,
EventDetailsConnection,
EventTypeArgs,
EventTypeConnection,
} from 'src/common/graphql/args/event.args';
import { JWTAuthGuard, RolesGuard } from 'src/common/guards';
import { GqlContext, JWTPayload } from 'src/common/interfaces';
import { Repository } from 'typeorm';
@Resolver(() => EventDetailsType)
export class EventResolver {
private readonly logger = new Logger(EventResolver.name);
constructor(
@Inject(JwtService)
private readonly jwtService: JwtService,
@InjectRepository(OrganizationEntity)
private readonly organizationRepository: Repository<OrganizationEntity>,
@InjectQueryService(EventEntity)
private readonly eventQueryService: QueryService<EventEntity>,
) {}
/**
*
* - I want to expose the relations in this method and query all the related entities. How can I achieve this?
*/
@Query(() => EventDetailsConnection, {
name: `events`,
description: `Retrieves a list of events.`,
})
async find(@Args() query: EventDetailsArgs) {
const events = await this.eventQueryService.query(query);
this.logger.debug({ events });
}
}
I’ve been using nestjs-query for a while, but I’m confused about how to expose and fetch relations when using custom endpoints. I could finds any guidance on the documentation. Could someone provide guidance on this.?
event.resolver.ts
event.args.ts
event.type.ts
event.entity.ts
organization.type.ts
organization.entity.ts