Skip to content

Commit 9571453

Browse files
committed
Chore: Change function name
1 parent 2ad33c1 commit 9571453

File tree

3 files changed

+19
-16
lines changed

3 files changed

+19
-16
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ You can solve them with Sending JWT token in `Http Header` with the `Authorizati
6969

7070
- Ensures that only the requested fields and necessary relations are retrieved, reducing over-fetching and improving performance.
7171

72-
- With using interceptor (name: `UseRepositoryInterceptor`) and paramDecorator (name: `GraphQLQueryToCondition`)
72+
- With using interceptor (name: `UseRepositoryInterceptor`) and paramDecorator (name: `GraphQLQueryToOption`)
7373

7474
#### How to use
7575

src/common/decorators/condition.decorator.ts renamed to src/common/decorators/option.decorator.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ const addKeyValuesInObject = <Entity>({
4343
return { relations, select };
4444
};
4545

46-
export function getConditionFromGqlQuery<Entity>(
46+
export function getOptionFromGqlQuery<Entity>(
4747
this: Repository<Entity>,
4848
query: string,
4949
hasCountType?: boolean,
@@ -159,7 +159,7 @@ const getCurrentGraphQLQuery = (ctx: GqlExecutionContext) => {
159159
return stack.join('\n');
160160
};
161161

162-
export const GraphQLQueryToCondition = <T>(hasCountType?: boolean) =>
162+
export const GraphQLQueryToOption = <T>(hasCountType?: boolean) =>
163163
createParamDecorator((_: unknown, context: ExecutionContext) => {
164164
const ctx = GqlExecutionContext.create(context);
165165
const request = ctx.getContext().req;
@@ -172,8 +172,11 @@ export const GraphQLQueryToCondition = <T>(hasCountType?: boolean) =>
172172
);
173173
}
174174

175-
const queryCondition: GetInfoFromQueryProps<T> =
176-
getConditionFromGqlQuery.call(repository, query, hasCountType);
175+
const queryOption: GetInfoFromQueryProps<T> = getOptionFromGqlQuery.call(
176+
repository,
177+
query,
178+
hasCountType,
179+
);
177180

178-
return queryCondition;
181+
return queryOption;
179182
})();

src/user/user.resolver.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import GraphQLJSON from 'graphql-type-json';
44

55
import { CustomCache } from 'src/cache/custom-cache.decorator';
66
import { UseAuthGuard } from 'src/common/decorators/auth-guard.decorator';
7-
import { GraphQLQueryToCondition } from 'src/common/decorators/condition.decorator';
7+
import { GraphQLQueryToOption } from 'src/common/decorators/option.decorator';
88
import { UseRepositoryInterceptor } from 'src/common/decorators/repository-interceptor.decorator';
99
import { GetManyInput, GetOneInput } from 'src/common/graphql/custom.input';
1010
import { GetInfoFromQueryProps } from 'src/common/graphql/utils/types';
@@ -25,10 +25,10 @@ export class UserResolver {
2525
getManyUserList(
2626
@Args({ name: 'input', nullable: true })
2727
condition: GetManyInput<User>,
28-
@GraphQLQueryToCondition<User>(true)
29-
info: GetInfoFromQueryProps<User>,
28+
@GraphQLQueryToOption<User>(true)
29+
option: GetInfoFromQueryProps<User>,
3030
) {
31-
return this.userService.getMany({ ...condition, ...info });
31+
return this.userService.getMany({ ...condition, ...option });
3232
}
3333

3434
@Query(() => User)
@@ -37,10 +37,10 @@ export class UserResolver {
3737
getOneUser(
3838
@Args({ name: 'input' })
3939
condition: GetOneInput<User>,
40-
@GraphQLQueryToCondition<User>()
41-
info: GetInfoFromQueryProps<User>,
40+
@GraphQLQueryToOption<User>()
41+
option: GetInfoFromQueryProps<User>,
4242
) {
43-
return this.userService.getOne({ ...condition, ...info });
43+
return this.userService.getOne({ ...condition, ...option });
4444
}
4545

4646
@Mutation(() => User)
@@ -66,12 +66,12 @@ export class UserResolver {
6666
@UseRepositoryInterceptor(User)
6767
getMe(
6868
@CurrentUser() user: User,
69-
@GraphQLQueryToCondition<User>()
70-
info: GetInfoFromQueryProps<User>,
69+
@GraphQLQueryToOption<User>()
70+
option: GetInfoFromQueryProps<User>,
7171
) {
7272
return this.userService.getOne({
7373
where: { id: user.id },
74-
...info,
74+
...option,
7575
});
7676
}
7777
}

0 commit comments

Comments
 (0)