From 0fe9580bae5c292f2760e123e88f569e60253df4 Mon Sep 17 00:00:00 2001 From: Tycho Bokdam Date: Thu, 28 Oct 2021 18:31:27 +0200 Subject: [PATCH] feat(query-graphql): allow descriptions to be defined in relations --- packages/query-graphql/src/resolvers/relations/helpers.ts | 2 +- .../src/resolvers/relations/read-relations.resolver.ts | 4 ++-- .../src/resolvers/relations/relations.interface.ts | 5 +++++ 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/packages/query-graphql/src/resolvers/relations/helpers.ts b/packages/query-graphql/src/resolvers/relations/helpers.ts index 7919013a0..e4131b8ec 100644 --- a/packages/query-graphql/src/resolvers/relations/helpers.ts +++ b/packages/query-graphql/src/resolvers/relations/helpers.ts @@ -9,4 +9,4 @@ export const flattenRelations = | Resolver export const removeRelationOpts = ( opts: ResolverRelation | ResolverRelationReference, ): ResolverMethodOpts => - omit(opts, 'DTO', 'keys', 'nullable', 'dtoName', 'relationName', 'disableRead', 'disableUpdate', 'disableRemove'); + omit(opts, 'DTO', 'keys', 'nullable', 'dtoName', 'relationName', 'disableRead', 'disableUpdate', 'disableRemove', 'description'); diff --git a/packages/query-graphql/src/resolvers/relations/read-relations.resolver.ts b/packages/query-graphql/src/resolvers/relations/read-relations.resolver.ts index 7ebe3cf2b..2ef336130 100644 --- a/packages/query-graphql/src/resolvers/relations/read-relations.resolver.ts +++ b/packages/query-graphql/src/resolvers/relations/read-relations.resolver.ts @@ -34,7 +34,7 @@ const ReadOneRelationMixin = @ResolverField( baseNameLower, () => relationDTO, - { nullable: relation.nullable, complexity: relation.complexity }, + { nullable: relation.nullable, complexity: relation.complexity, description: relation?.description }, commonResolverOpts, { interceptors: [AuthorizerInterceptor(DTOClass)] }, ) @@ -86,7 +86,7 @@ const ReadManyRelationMixin = @ResolverField( pluralBaseNameLower, () => CT.resolveType, - { nullable: relation.nullable, complexity: relation.complexity }, + { nullable: relation.nullable, complexity: relation.complexity, description: relation?.description }, commonResolverOpts, { interceptors: [AuthorizerInterceptor(DTOClass)] }, ) diff --git a/packages/query-graphql/src/resolvers/relations/relations.interface.ts b/packages/query-graphql/src/resolvers/relations/relations.interface.ts index a214839d3..c36393416 100644 --- a/packages/query-graphql/src/resolvers/relations/relations.interface.ts +++ b/packages/query-graphql/src/resolvers/relations/relations.interface.ts @@ -68,6 +68,11 @@ export type ResolverRelation = { */ allowFiltering?: boolean; + /** + * Description of the relation. + */ + description?: string; + complexity?: Complexity; auth?: AuthorizerOptions;