Skip to content

Commit

Permalink
feat(query-graphql): Added support for complexity to queries and mu…
Browse files Browse the repository at this point in the history
…tations
  • Loading branch information
TriPSs committed May 23, 2023
1 parent 6abe0c2 commit c2699ab
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export interface BaseResolverOptions {
export interface ResolverMethodOpts extends BaseResolverOptions {
/** Set to true to disable the endpoint */
disabled?: boolean
complexity?: Complexity
}

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/query-graphql/src/resolvers/aggregate.resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export const Aggregateable =
class AggregateResolverBase extends BaseClass {
@ResolverQuery(
() => [AR],
{ name: queryName, description: opts?.description },
{ name: queryName, description: opts?.description, complexity: opts?.complexity },
commonResolverOpts,
{ interceptors: [AuthorizerInterceptor(DTOClass)] },
opts ?? {}
Expand Down
4 changes: 2 additions & 2 deletions packages/query-graphql/src/resolvers/create.resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ export const Creatable =
class CreateResolverBase extends BaseClass {
@ResolverMutation(
() => DTOClass,
{ name: createOneMutationName, description: opts?.one?.description },
{ name: createOneMutationName, description: opts?.one?.description, complexity: opts?.one?.complexity },
commonResolverOpts,
{
interceptors: [HookInterceptor(HookTypes.BEFORE_CREATE_ONE, CreateDTOClass, DTOClass), AuthorizerInterceptor(DTOClass)]
Expand All @@ -147,7 +147,7 @@ export const Creatable =

@ResolverMutation(
() => [DTOClass],
{ name: createManyMutationName, description: opts?.many?.description },
{ name: createManyMutationName, description: opts?.many?.description, complexity: opts?.many?.complexity },
{ ...commonResolverOpts },
{
interceptors: [HookInterceptor(HookTypes.BEFORE_CREATE_MANY, CreateDTOClass, DTOClass), AuthorizerInterceptor(DTOClass)]
Expand Down
4 changes: 2 additions & 2 deletions packages/query-graphql/src/resolvers/delete.resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ export const Deletable =
class DeleteResolverBase extends BaseClass {
@ResolverMutation(
() => DeleteOneResponse,
{ name: deleteOneMutationName, description: opts?.one?.description },
{ name: deleteOneMutationName, description: opts?.one?.description, complexity: opts?.one?.complexity },
commonResolverOpts,
{ interceptors: [HookInterceptor(HookTypes.BEFORE_DELETE_ONE, DTOClass), AuthorizerInterceptor(DTOClass)] },
opts.one ?? {}
Expand All @@ -143,7 +143,7 @@ export const Deletable =

@ResolverMutation(
() => DMR,
{ name: deleteManyMutationName, description: opts?.many?.description },
{ name: deleteManyMutationName, description: opts?.many?.description, complexity: opts?.many?.complexity },
commonResolverOpts,
{ interceptors: [HookInterceptor(HookTypes.BEFORE_DELETE_MANY, DTOClass), AuthorizerInterceptor(DTOClass)] },
opts.many ?? {}
Expand Down
8 changes: 6 additions & 2 deletions packages/query-graphql/src/resolvers/read.resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,11 @@ export const Readable =
class ReadResolverBase extends BaseClass {
@ResolverQuery(
() => DTOClass,
{ name: readOneQueryName, description: opts?.one?.description },
{
name: readOneQueryName,
description: opts?.one?.description,
complexity: opts?.one?.complexity
},
commonResolverOpts,
{ interceptors: [HookInterceptor(HookTypes.BEFORE_FIND_ONE, DTOClass), AuthorizerInterceptor(DTOClass)] },
opts.one ?? {}
Expand All @@ -93,7 +97,7 @@ export const Readable =

@ResolverQuery(
() => QueryArgs.ConnectionType.resolveType,
{ name: readManyQueryName, description: opts?.many?.description },
{ name: readManyQueryName, description: opts?.many?.description, complexity: opts?.many?.complexity },
commonResolverOpts,
{ interceptors: [HookInterceptor(HookTypes.BEFORE_QUERY_MANY, DTOClass), AuthorizerInterceptor(DTOClass)] },
opts.many ?? {}
Expand Down
4 changes: 2 additions & 2 deletions packages/query-graphql/src/resolvers/update.resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ export const Updateable =
class UpdateResolverBase extends BaseClass {
@ResolverMutation(
() => DTOClass,
{ name: updateOneMutationName, description: opts?.one?.description },
{ name: updateOneMutationName, description: opts?.one?.description, complexity: opts?.one?.complexity },
{
interceptors: [HookInterceptor(HookTypes.BEFORE_UPDATE_ONE, UpdateDTOClass, DTOClass), AuthorizerInterceptor(DTOClass)]
},
Expand All @@ -152,7 +152,7 @@ export const Updateable =

@ResolverMutation(
() => UMR,
{ name: updateManyMutationName, description: opts?.many?.description },
{ name: updateManyMutationName, description: opts?.many?.description, complexity: opts?.many?.complexity },
{
interceptors: [HookInterceptor(HookTypes.BEFORE_UPDATE_MANY, UpdateDTOClass, DTOClass), AuthorizerInterceptor(DTOClass)]
},
Expand Down

0 comments on commit c2699ab

Please sign in to comment.