Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}
@Query('listHomes')
async findAll(@Args('filter') filter?: ModelHomeFilterInput, @Args('limit') limit?: number): Promise {
return this.homeService.findAll({
where: {
...filter,
isDeleted: {
eq: false
}
},
take: limit
});
}
@Query('myHomes')
@UseGuards(GraphqlGuard)
async findAllMyHomes(@CurrentUser() user: User): Promise {
return this.homeService.findAll({
where: {
owner: {
eq: user.id.toString()
},
isDeleted: {
eq: false
}
}
});
}
@Query('getHome')
async findOneById(@Args('id') id: string): Promise {
__decorate([
graphql_1.Query('findUsersInRole'),
decorators_1.Permission({ name: 'find_users_in_role', identify: 'user:findUsersInRole', action: 'find' }),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Object, Object]),
__metadata("design:returntype", Promise)
], UserResolver.prototype, "findUsersInRole", null);
__decorate([
graphql_1.Query('findUsersInOrganization'),
decorators_1.Permission({ name: 'find_users_in_organization', identify: 'user:findUsersInOrganization', action: 'find' }),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Object, Object]),
__metadata("design:returntype", Promise)
], UserResolver.prototype, "findUsersInOrganization", null);
__decorate([
graphql_1.Query('findAllUsers'),
decorators_1.Permission({ name: 'find_all_users', identify: 'user:findAllUsers', action: 'find' }),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Object, Object]),
__metadata("design:returntype", Promise)
], UserResolver.prototype, "findAllUsers", null);
UserResolver = __decorate([
graphql_1.Resolver(),
decorators_1.Resource({ name: 'user_manage', identify: 'user:manage' }),
__param(0, common_1.Inject(user_service_1.UserService)),
__metadata("design:paramtypes", [user_service_1.UserService])
], UserResolver);
exports.UserResolver = UserResolver;
import { UsePipes } from '@nestjs/common';
import { Args, Context, Mutation, Query, Resolver } from '@nestjs/graphql';
import { signupInputSchema } from '@votingapp/common';
import { MyContext } from 'src/types/myContext';
import { YupValidationPipe } from '../pipes/yupValidationPipe';
import { LoginInput } from './input/user.loginInput';
import { SignupInput } from './input/user.singupInput';
import { ErrorResponse } from './shared/errorResponse';
import { User } from './user.entity';
import { UserService } from './user.service';
@Resolver(User)
export class UserResolver {
constructor(private readonly userService: UserService) {}
@Query(() => String)
async hello() {
return 'hello world';
}
@Mutation(() => [ErrorResponse], { nullable: true })
@UsePipes(new YupValidationPipe(signupInputSchema))
async signup(
@Args('signupInput') signupInput: SignupInput,
): Promise {
return this.userService.signup(signupInput);
}
@Mutation(() => [ErrorResponse], { nullable: true })
async login(
@Args('loginInput') loginInput: LoginInput,
@Context() ctx: MyContext,
import { Resolver, Mutation, Args, Query, Context } from '@nestjs/graphql'
import { getMongoRepository } from 'typeorm'
import { ForbiddenError } from 'apollo-server-core'
import { Room, User } from '@models'
import { CreateRoomInput } from '../generator/graphql.schema'
@Resolver('Room')
export class RoomResolver {
@Query(() => [Room])
async rooms(): Promise {
return getMongoRepository(Room).find({
cache: true,
})
}
@Query(() => Room)
async room(@Args('_id') _id: string): Promise {
const room = await getMongoRepository(Room).findOne({
_id,
})
if (!room) {
throw new ForbiddenError('Room not found.')
}
import { Query, Resolver } from "@nestjs/graphql";
import { UseGuards } from "@nestjs/common";
import { UserGuard } from "@notadd/authentication/guards/user.guard";
@Resolver('Log')
export class LogResolvers {
constructor(private readonly service: LogService) {
}
@Query()
@UseGuards(UserGuard)
async getLogs(): Promise {
return await this.service.getLogs();
}
@Query()
@UseGuards(UserGuard)
async getLogById(obj, { id }): Promise {
return await this.service.getLogById(id);
}
}
import { ArticleService } from '../services/article.service';
import { InputArticle, UpdateArticle } from '../interfaces/article.interface';
@Resolver()
export class ArticleResolver {
constructor(
private readonly articleService: ArticleService
) { }
@Query('getAllArticle')
async getAllArticle(obj, body: { classifyId: number, createdAt: string, endTime: string, title: string, username: string, top: boolean, pageNumber: number, pageSize: number }) {
const result = await this.articleService.getAllArticle(body.classifyId, body.createdAt, body.endTime, body.title, body.username, body.top, body.pageNumber, body.pageSize);
return { code: 200, message: '查询成功!', data: result.exist, total: result.total };
}
@Query('userGetArticles')
async userGetArticles(obj, body: { alias: string, pageNumber: number, pageSize: number }) {
const result = await this.articleService.userGetArticles(body.alias, body.pageNumber, body.pageSize);
return { code: 200, message: '查询成功!', data: result.exist, total: result.total };
}
@Query('getRecycleArticle')
async getRecycleArticle(obj, body: { classifyId: number, createdAt: string, endTime: string, title: string, username: string, top: boolean, pageNumber: number, pageSize: number }) {
const result = await this.articleService.getRecycleArticle(body.classifyId, body.createdAt, body.endTime, body.title, body.username, body.top, body.pageNumber, body.pageSize);
return { code: 200, message: '查询成功!', data: result.exist, total: result.total };
}
@Query('getCheckArticle')
async getCheckArticle(obj, body: { classifyId: number, createdAt: string, endTime: string, title: string, username: string, top: boolean, pageNumber: number, pageSize: number }) {
const result = await this.articleService.getCheckArticle(body.classifyId, body.createdAt, body.endTime, body.title, body.username, body.top, body.pageNumber, body.pageSize);
return { code: 200, message: '查询成功!', data: result.exist, total: result.total };
}
} else if (args.slug) {
result = await this.productService.findOneBySlug(ctx, args.slug);
} else {
throw new UserInputError(`error.product-id-or-slug-must-be-provided`);
}
if (!result) {
return;
}
if (result.enabled === false) {
return;
}
result.facetValues = result.facetValues.filter(fv => !fv.facet.isPrivate) as any;
return result;
}
@Query()
async collections(
@Ctx() ctx: RequestContext,
@Args() args: QueryCollectionsArgs,
): Promise>> {
const options: ListQueryOptions = {
...args.options,
filter: {
...(args.options && args.options.filter),
isPrivate: { eq: false },
},
};
return this.collectionService.findAll(ctx, options || undefined);
}
@Query()
async collection(
@Resolver('HomeMedia')
@UseGuards(GraphqlGuard)
export class HomeMediaResolver {
private pubSub = new PubSub();
private logger = new AppLogger(HomeMediaResolver.name);
@Client({ transport: Transport.TCP })
private client: ClientProxy;
constructor(private readonly homeMediaService: HomeMediaService) {
}
@Query('getHomeMedia')
async findAll(@Args('homeId') homeId: string): Promise {
return this.homeMediaService.findAll({where: {homeId: {eq: homeId}}});
}
@Mutation('createHomeMedia')
async create(@CurrentUser() user: User, @Args('createHomeMediaInput') args: CreateHomeMediaInput): Promise {
const createdHomeMedia = await this.homeMediaService.create(args);
await this.pubSub.publish('homeMediaCreated', {homeMediaCreated: createdHomeMedia});
return createdHomeMedia;
}
@Mutation('updateHomeMedia')
async update(@CurrentUser() user: User, @Args('updateHomeMediaInput') args: UpdateHomeMediaInput): Promise {
const updatedHomeMedia = await this.homeMediaService.update(args);
await this.pubSub.publish('homeMediaUpdated', {homeMediaCreated: updatedHomeMedia});
return updatedHomeMedia;
import * as path from 'path';
@Resolver('Instance')
export class InstanceResolver {
constructor(
private readonly instanceRepository: InstanceRepository,
private readonly instanceLister: InstanceLister,
private readonly instanceModelToTypeMapper: InstanceModelToTypeMapper,
private readonly definitionRepository: DefinitionRepository,
private readonly instantiator: InstanceCreatorComponent,
private readonly definitionModelToTypeMapper: DefinitionModelToTypeMapper,
private readonly commandLogRepository: CommandLogRepository,
private readonly commandLogModelToTypeMapper: CommandLogModelToTypeMapper,
) {}
@Query('instances')
async getAll(@Args() args?: any): Promise {
const criteria = this.applyInstanceFilterArgumentToCriteria(
{},
args as ResolverInstanceFilterArgumentsInterface,
);
const instances = await this.instanceLister.getList(
criteria,
args as ResolverPaginationArgumentsInterface,
);
return this.instanceModelToTypeMapper.mapMany(instances);
}
@Query('instance')
async getOne(@Args('id') id: string): Promise {
const instance = await this.instanceRepository.findById(id);
import { Mutation, Query, ResolveProperty, Resolver } from '@nestjs/graphql';
import { AuthGuard } from '@nestjs/passport';
import { ApiQuery } from 'common/models/api-query.model';
import { BookmarkService } from './bookmark.service';
@Resolver('Bookmark')
export class BookmarkResolver {
constructor(private readonly bookmarkService: BookmarkService) {}
@ResolveProperty('book')
async getBook({ bookId }, args, context, info) {
return await context.loaders.booksLoader.load(bookId);
}
@Query('bookmarks')
@UseGuards(AuthGuard('jwt'))
async getBookmarks(obj, { type, skip, first }, context, info) {
const userId = info.rootValue.user._id;
return await this.bookmarkService.getByType(
new ApiQuery({ type, userId }, first, skip),
);
}
@Mutation()
@UseGuards(AuthGuard('jwt'))
async addToBookmarks(obj, { type, bookId }, context, info) {
const userId = info.rootValue.user._id;
return await this.bookmarkService.addToBookmarks(type, userId, bookId);
}
@Mutation()