From cb3dc624328077267eded288f7cfbd5a6e9b7806 Mon Sep 17 00:00:00 2001 From: doug-martin Date: Mon, 22 Feb 2021 16:58:46 -0700 Subject: [PATCH] feat(graphql,relations): Revert back to unPagedRelation --- documentation/docs/faq.md | 2 +- documentation/docs/graphql/relations.mdx | 60 +++++++++---------- .../migration-guides/v0.22.x-to-v0.23.x.mdx | 8 +-- documentation/docs/persistence/services.mdx | 2 +- examples/hooks/src/tag/dto/tag.dto.ts | 4 +- .../hooks/src/todo-item/dto/todo-item.dto.ts | 6 +- examples/no-paging/src/tag/dto/tag.dto.ts | 4 +- .../src/todo-item/dto/todo-item.dto.ts | 6 +- .../__fixtures__/filter-input-type.graphql | 4 +- .../auth/default-crud-auth.service.spec.ts | 6 +- .../decorators/relation.decorator.spec.ts | 24 +++++--- .../federation-relation.resolver.graphql | 2 +- .../federation/federation.resolver.spec.ts | 8 +-- .../__tests__/types/query/filter.type.spec.ts | 8 +-- .../src/decorators/hook.decorator.ts | 2 +- .../query-graphql/src/decorators/index.ts | 4 +- .../src/decorators/relation.decorator.ts | 4 +- packages/query-graphql/src/index.ts | 4 +- .../src/resolvers/read.resolver.ts | 1 - 19 files changed, 82 insertions(+), 77 deletions(-) diff --git a/documentation/docs/faq.md b/documentation/docs/faq.md index 23ea918b3..ba8b7d633 100644 --- a/documentation/docs/faq.md +++ b/documentation/docs/faq.md @@ -65,7 +65,7 @@ Yes! The `@FilterableField` decorator accepts the same arguments as the `@Field` decorator from `@nestjs/graphql` -The `@Relation` `@FilterableRelation`, `@AllRelations`, `@FilterableAllRelations`, `@OffsetConnection`, `@FilterableOffsetConnection`, `@CursorConnection`, and `@FilterableCursorConnection` decorators also accept a complexity option. +The `@Relation` `@FilterableRelation`, `@UnPagedRelation`, `@FilterableUnPagedRelation`, `@OffsetConnection`, `@FilterableOffsetConnection`, `@CursorConnection`, and `@FilterableCursorConnection` decorators also accept a complexity option. To read more about complexity [see the nestjs docs](https://docs.nestjs.com/graphql/complexity) diff --git a/documentation/docs/graphql/relations.mdx b/documentation/docs/graphql/relations.mdx index 014a1286d..4c61fe203 100644 --- a/documentation/docs/graphql/relations.mdx +++ b/documentation/docs/graphql/relations.mdx @@ -9,8 +9,8 @@ When using the `nestjs-query` you can specify relations that should be exposed f * `@Relation` - A relation that is a single value (one-to-one, many-to-one) * `@FilterableRelation` - A `@Relation` that enables filtering the parent by fields of the relation `DTO`. -* `@AllRelations` - An array of relations (e.g, many-to-many, one-to-many) that returns all of the related records. -* `@FilterableAllRelations` - An `@AllRelations` that enables filtering the parent by fields of the relation +* `@UnPagedRelation` - An array of relations (e.g, many-to-many, one-to-many) that returns all of the related records. +* `@FilterableUnPagedRelation` - An `@UnPagedRelation` that enables filtering the parent by fields of the relation `DTO`. * `@OffsetConnection` - A connection that represents a collection (e.g, many-to-many, one-to-many) that uses `offset` based pagination. @@ -22,7 +22,7 @@ When using the `nestjs-query` you can specify relations that should be exposed f connection `DTO`. :::warning -`@FilterableAllRelations`, `@FilterableOffsetConnection`, and `@FilterableCursorConnection` are not supported by +`@FilterableUnPagedRelation`, `@FilterableOffsetConnection`, and `@FilterableCursorConnection` are not supported by mongoose! ::: @@ -295,9 +295,9 @@ In this example we'll find all subTasks that are related to a `todoItem` with a ``` -## @AllRelations +## @UnPagedRelation -You can also use the `@AllRelations` decorator to define a relation that does not use paging and returns an array +You can also use the `@UnPagedRelation` decorator to define a relation that does not use paging and returns an array of all the related records. ### Example @@ -305,12 +305,12 @@ You can also use the `@AllRelations` decorator to define a relation that does no Based on the entity definition above we can define a `TodoItemDTO` with a `subTasks` relation. ```ts title="todo-item/todo-item.dto.ts" {6} -import { FilterableField, AllRelations } from '@nestjs-query/query-graphql'; +import { FilterableField, UnPagedRelation } from '@nestjs-query/query-graphql'; import { ObjectType, ID, GraphQLISODateTime } from '@nestjs/graphql'; import { SubTaskDTO } from '../sub-task/sub-task.dto' @ObjectType('TodoItem') -@AllRelations('subTasks', () => SubTaskDTO, { disableRemove: true }) +@UnPagedRelation('subTasks', () => SubTaskDTO, { disableRemove: true }) export class TodoItemDTO { @FilterableField(() => ID) id!: string; @@ -394,14 +394,14 @@ input RelationsInput { If `disableRemove` was set to `false` or not specified a `removeSubTasksFromTodoItem` mutation would also be exposed with the same arguments as `addSubTasksToTodoItem`. ::: -## @FilterableAllRelations +## @FilterableUnPagedRelation -The `@FilterableAllRelations` extends the `@AllRelations` decorator exposing the ability to filter the `DTO` that +The `@FilterableUnPagedRelation` extends the `@UnPagedRelation` decorator exposing the ability to filter the `DTO` that defines the relation by relation properties. :::warning -The `@FilterableAllRelations` decorator will **only** work with relations defined by the orm used (e.g. `typeorm`, -`sequelize`). If your relations are federated or you are using `mongoose` you cannot use the `@FilterableAllRelations` +The `@FilterableUnPagedRelation` decorator will **only** work with relations defined by the orm used (e.g. `typeorm`, +`sequelize`). If your relations are federated or you are using `mongoose` you cannot use the `@FilterableUnPagedRelation` decorator. ::: @@ -411,12 +411,12 @@ In this example we'll use the same Entities defined above to create a graphql en by `SubTasks`. ```ts title="sub-task/sub-task.dto.ts" {6} -import { FilterableField, FilterableAllRelations } from '@nestjs-query/query-graphql'; +import { FilterableField, FilterableUnPagedRelation } from '@nestjs-query/query-graphql'; import { ObjectType, ID, GraphQLISODateTime } from '@nestjs/graphql'; import { SubTaskDTO } from '../sub-task/sub-task.dto' @ObjectType('TodoItem') -@FilterableAllRelations('subTasks', () => SubTaskDTO, { disableRemove: true }) +@FilterableUnPagedRelation('subTasks', () => SubTaskDTO, { disableRemove: true }) export class TodoItemDTO { @FilterableField(() => ID) id!: string; @@ -434,8 +434,8 @@ export class TodoItemDTO { updated!: Date; } ``` -Notice the use of `@FilterableAllRelations` instead of `@AllRelations`, by using the -`@FilterableAllRelations` version `nestjs-query` will allow filtering on the `subTasks` relation. +Notice the use of `@FilterableUnPagedRelation` instead of `@UnPagedRelation`, by using the +`@FilterableUnPagedRelation` version `nestjs-query` will allow filtering on the `subTasks` relation. The module definition remains the same. @@ -1041,7 +1041,7 @@ Sometimes you may want to expose a relation that has a different name when persi { label: 'Relation', value: 'relation', }, { label: 'CursorConnection', value: 'cursor-connection', }, { label: 'OffsetConnection', value: 'offset-connection', }, - { label: 'AllRelations', value: 'all-relations', }, + { label: 'UnPagedRelation', value: 'unpaged-relation', }, ] }> @@ -1068,11 +1068,11 @@ Sometimes you may want to expose a relation that has a different name when persi ``` - + ```ts // expose subTasks as subTaskConnection in graphql -@AllRelations('subTasks', () => SubTaskDTO, { relationName: 'subTasks' }) +@UnPagedRelation('subTasks', () => SubTaskDTO, { relationName: 'subTasks' }) ``` @@ -1089,7 +1089,7 @@ To disable the `read` `queries` you can set the `disableRead` option to `true`. { label: 'Relation', value: 'relation', }, { label: 'CursorConnection', value: 'cursor-connection', }, { label: 'OffsetConnection', value: 'offset-connection', }, - { label: 'AllRelations', value: 'all-relations', }, + { label: 'UnPagedRelation', value: 'unpaged-relation', }, ] }> @@ -1116,11 +1116,11 @@ To disable the `read` `queries` you can set the `disableRead` option to `true`. ``` - + ```ts // disable reading the relation -@AllRelations('subTaskConnection', () => SubTaskDTO, { disableRead: true }) +@UnPagedRelation('subTaskConnection', () => SubTaskDTO, { disableRead: true }) ``` @@ -1137,7 +1137,7 @@ To disable the `update` `mutations` you can set the `disableUpdate` option to `t { label: 'Relation', value: 'relation', }, { label: 'CursorConnection', value: 'cursor-connection', }, { label: 'OffsetConnection', value: 'offset-connection', }, - { label: 'AllRelations', value: 'all-relations', }, + { label: 'UnPagedRelation', value: 'unpaged-relation', }, ] }> @@ -1164,11 +1164,11 @@ To disable the `update` `mutations` you can set the `disableUpdate` option to `t ``` - + ```ts // disable updating subTasks -@AllRelations('subTasks', () => SubTaskDTO, { disableUpdate: true }) +@UnPagedRelation('subTasks', () => SubTaskDTO, { disableUpdate: true }) ``` @@ -1185,7 +1185,7 @@ To disable the `remove` `mutations` you can set the `disableRemove` option to `t { label: 'Relation', value: 'relation', }, { label: 'CursorConnection', value: 'cursor-connection', }, { label: 'OffsetConnection', value: 'offset-connection', }, - { label: 'AllRelations', value: 'all-relations', }, + { label: 'UnPagedRelation', value: 'unpaged-relation', }, ] }> @@ -1212,11 +1212,11 @@ To disable the `remove` `mutations` you can set the `disableRemove` option to `t ``` - + ```ts // disable removing subTasks from the relations -@AllRelations('subTasks', () => SubTaskDTO, { disableRemove: true }) +@UnPagedRelation('subTasks', () => SubTaskDTO, { disableRemove: true }) ``` @@ -1270,7 +1270,7 @@ We can then add it to our relations { label: 'Relation', value: 'relation', }, { label: 'CursorConnection', value: 'cursor-connection', }, { label: 'OffsetConnection', value: 'offset-connection', }, - { label: 'AllRelations', value: 'all-relations', }, + { label: 'UnPagedRelation', value: 'unpaged-relation', }, ] }> @@ -1297,11 +1297,11 @@ We can then add it to our relations ``` - + ```ts // Add the AuthGuard using the guards option -@AllRelations('subTasks', () => SubTaskDTO, { guards: [AuthGuard] }) +@UnPagedRelation('subTasks', () => SubTaskDTO, { guards: [AuthGuard] }) ``` diff --git a/documentation/docs/migration-guides/v0.22.x-to-v0.23.x.mdx b/documentation/docs/migration-guides/v0.22.x-to-v0.23.x.mdx index 4acb0685b..9ec7173ba 100644 --- a/documentation/docs/migration-guides/v0.22.x-to-v0.23.x.mdx +++ b/documentation/docs/migration-guides/v0.22.x-to-v0.23.x.mdx @@ -74,8 +74,8 @@ In `v0.23.0` the decorators have been renamed to be more explicit. * `@Relation` - A relation that is a single value (one-to-one, many-to-one) * `@FilterableRelation` - A `@Relation` that enables filtering the parent by fields of the relation `DTO`. -* `@AllRelations` - An array of relations (e.g, many-to-many, one-to-many) that returns all the related records. -* `@FilterableAllRelations` - An `@AllRelations` that enables filtering the parent by fields of the relation +* `@UnPagedRelation` - An array of relations (e.g, many-to-many, one-to-many) that returns all the related records. +* `@FilterableUnPagedRelation` - An `@UnPagedRelation` that enables filtering the parent by fields of the relation `DTO`. * `@OffsetConnection` - A connection that represents a collection (e.g, many-to-many, one-to-many) that uses `offset` based pagination. @@ -111,14 +111,14 @@ In previous versions the `OFFSET` paging strategy returned an array of relations //old @Relation('subTasks', () => [TodoItem], {pagingStrategy: PagingStrategies.NONE}) //new -@AllRelations('subTasks', () => TodoItem) +@UnPagedRelation('subTasks', () => TodoItem) ``` ```ts //old @FilterableRelation('subTasks', () => [TodoItem], {pagingStrategy: PagingStrategies.NONE}) //new -@FilterableAllRelations('subTasks', () => TodoItem) +@FilterableUnPagedRelation('subTasks', () => TodoItem) ``` ```ts diff --git a/documentation/docs/persistence/services.mdx b/documentation/docs/persistence/services.mdx index 9b368798c..aa6443ca9 100644 --- a/documentation/docs/persistence/services.mdx +++ b/documentation/docs/persistence/services.mdx @@ -609,7 +609,7 @@ This section only applies when you combine your DTO and entity and are using Typ When your DTO and entity are the same class and you have relations defined, you should not decorate your the relations in the DTO with `@Field` or `@FilterableField`. -Instead decorate the class with `@CursorConnection`, `@OffsetConnection`, '@AllRelations' or `@Relation`. +Instead decorate the class with `@CursorConnection`, `@OffsetConnection`, '@UnPagedRelation' or `@Relation`. ### Example diff --git a/examples/hooks/src/tag/dto/tag.dto.ts b/examples/hooks/src/tag/dto/tag.dto.ts index 62babe98a..d5cffad20 100644 --- a/examples/hooks/src/tag/dto/tag.dto.ts +++ b/examples/hooks/src/tag/dto/tag.dto.ts @@ -1,7 +1,7 @@ /* eslint-disable no-param-reassign */ import { FilterableField, - FilterableConnection, + FilterableCursorConnection, BeforeCreateOne, BeforeCreateMany, BeforeUpdateOne, @@ -14,7 +14,7 @@ import { TodoItemDTO } from '../../todo-item/dto/todo-item.dto'; @ObjectType('Tag') @KeySet(['id']) -@FilterableConnection('todoItems', () => TodoItemDTO) +@FilterableCursorConnection('todoItems', () => TodoItemDTO) @BeforeCreateOne(CreatedByHook) @BeforeCreateMany(CreatedByHook) @BeforeUpdateOne(UpdatedByHook) diff --git a/examples/hooks/src/todo-item/dto/todo-item.dto.ts b/examples/hooks/src/todo-item/dto/todo-item.dto.ts index 2acf4271e..aad42342a 100644 --- a/examples/hooks/src/todo-item/dto/todo-item.dto.ts +++ b/examples/hooks/src/todo-item/dto/todo-item.dto.ts @@ -1,4 +1,4 @@ -import { FilterableField, FilterableConnection, KeySet } from '@nestjs-query/query-graphql'; +import { FilterableField, FilterableCursorConnection, KeySet } from '@nestjs-query/query-graphql'; import { ObjectType, ID, GraphQLISODateTime } from '@nestjs/graphql'; import { AuthGuard } from '../../auth/auth.guard'; import { SubTaskDTO } from '../../sub-task/dto/sub-task.dto'; @@ -6,8 +6,8 @@ import { TagDTO } from '../../tag/dto/tag.dto'; @ObjectType('TodoItem') @KeySet(['id']) -@FilterableConnection('subTasks', () => SubTaskDTO, { disableRemove: true, guards: [AuthGuard] }) -@FilterableConnection('tags', () => TagDTO, { guards: [AuthGuard] }) +@FilterableCursorConnection('subTasks', () => SubTaskDTO, { disableRemove: true, guards: [AuthGuard] }) +@FilterableCursorConnection('tags', () => TagDTO, { guards: [AuthGuard] }) export class TodoItemDTO { @FilterableField(() => ID) id!: number; diff --git a/examples/no-paging/src/tag/dto/tag.dto.ts b/examples/no-paging/src/tag/dto/tag.dto.ts index 86b3996bc..f97143e05 100644 --- a/examples/no-paging/src/tag/dto/tag.dto.ts +++ b/examples/no-paging/src/tag/dto/tag.dto.ts @@ -1,9 +1,9 @@ -import { FilterableField, AllRelations } from '@nestjs-query/query-graphql'; +import { FilterableField, UnPagedRelation } from '@nestjs-query/query-graphql'; import { ObjectType, ID, GraphQLISODateTime } from '@nestjs/graphql'; import { TodoItemDTO } from '../../todo-item/dto/todo-item.dto'; @ObjectType('Tag') -@AllRelations('todoItems', () => TodoItemDTO) +@UnPagedRelation('todoItems', () => TodoItemDTO) export class TagDTO { @FilterableField(() => ID) id!: number; diff --git a/examples/no-paging/src/todo-item/dto/todo-item.dto.ts b/examples/no-paging/src/todo-item/dto/todo-item.dto.ts index b4911e2ce..8f736fd3c 100644 --- a/examples/no-paging/src/todo-item/dto/todo-item.dto.ts +++ b/examples/no-paging/src/todo-item/dto/todo-item.dto.ts @@ -1,11 +1,11 @@ -import { FilterableField, AllRelations } from '@nestjs-query/query-graphql'; +import { FilterableField, UnPagedRelation } from '@nestjs-query/query-graphql'; import { ObjectType, ID, GraphQLISODateTime } from '@nestjs/graphql'; import { SubTaskDTO } from '../../sub-task/dto/sub-task.dto'; import { TagDTO } from '../../tag/dto/tag.dto'; @ObjectType('TodoItem') -@AllRelations('subTasks', () => SubTaskDTO, { disableRemove: true }) -@AllRelations('tags', () => TagDTO) +@UnPagedRelation('subTasks', () => SubTaskDTO, { disableRemove: true }) +@UnPagedRelation('tags', () => TagDTO) export class TodoItemDTO { @FilterableField(() => ID) id!: number; diff --git a/packages/query-graphql/__tests__/__fixtures__/filter-input-type.graphql b/packages/query-graphql/__tests__/__fixtures__/filter-input-type.graphql index 640f0c987..72a42fdd5 100644 --- a/packages/query-graphql/__tests__/__fixtures__/filter-input-type.graphql +++ b/packages/query-graphql/__tests__/__fixtures__/filter-input-type.graphql @@ -18,7 +18,7 @@ input TestDtoFilter { filterableRelation: TestFilterDtoFilterTestRelationDtoFilter filterableCursorConnection: TestFilterDtoFilterTestRelationDtoFilter filterableOffsetConnection: TestFilterDtoFilterTestRelationDtoFilter - filterableAllRelations: TestFilterDtoFilterTestRelationDtoFilter + filterableUnPagedRelations: TestFilterDtoFilterTestRelationDtoFilter } input TestFilterDtoFilter { @@ -37,7 +37,7 @@ input TestFilterDtoFilter { filterableRelation: TestFilterDtoFilterTestRelationDtoFilter filterableCursorConnection: TestFilterDtoFilterTestRelationDtoFilter filterableOffsetConnection: TestFilterDtoFilterTestRelationDtoFilter - filterableAllRelations: TestFilterDtoFilterTestRelationDtoFilter + filterableUnPagedRelations: TestFilterDtoFilterTestRelationDtoFilter } input NumberFieldComparison { diff --git a/packages/query-graphql/__tests__/auth/default-crud-auth.service.spec.ts b/packages/query-graphql/__tests__/auth/default-crud-auth.service.spec.ts index 6a15a3dd4..866296949 100644 --- a/packages/query-graphql/__tests__/auth/default-crud-auth.service.spec.ts +++ b/packages/query-graphql/__tests__/auth/default-crud-auth.service.spec.ts @@ -2,7 +2,7 @@ import { Test, TestingModule } from '@nestjs/testing'; import { Filter } from '@nestjs-query/core'; import { Injectable } from '@nestjs/common'; -import { Authorizer, Relation, Authorize, AllRelations } from '../../src'; +import { Authorizer, Relation, Authorize, UnPagedRelation } from '../../src'; import { getAuthorizerToken } from '../../src/auth'; import { createAuthorizerProviders } from '../../src/providers'; @@ -39,7 +39,7 @@ describe('createDefaultAuthorizer', () => { @Relation('relations', () => TestRelation, { auth: { authorize: (ctx: UserContext) => ({ relationOwnerId: { eq: ctx.user.id } }) }, }) - @AllRelations('allDecoratorRelations', () => TestDecoratorRelation) + @UnPagedRelation('unPagedDecoratorRelations', () => TestDecoratorRelation) @Relation('authorizerRelation', () => RelationWithAuthorizer) class TestDTO { ownerId!: number; @@ -79,7 +79,7 @@ describe('createDefaultAuthorizer', () => { it('should create an auth filter for relations using the default auth decorator', async () => { const authorizer = testingModule.get>(getAuthorizerToken(TestDTO)); - const filter = await authorizer.authorizeRelation('allDecoratorRelations', { user: { id: 2 } }); + const filter = await authorizer.authorizeRelation('unPagedDecoratorRelations', { user: { id: 2 } }); expect(filter).toEqual({ decoratorOwnerId: { eq: 2 } }); }); diff --git a/packages/query-graphql/__tests__/decorators/relation.decorator.spec.ts b/packages/query-graphql/__tests__/decorators/relation.decorator.spec.ts index f297710e2..225b30492 100644 --- a/packages/query-graphql/__tests__/decorators/relation.decorator.spec.ts +++ b/packages/query-graphql/__tests__/decorators/relation.decorator.spec.ts @@ -1,12 +1,18 @@ // eslint-disable-next-line max-classes-per-file import { ObjectType } from '@nestjs/graphql'; -import { Relation, PagingStrategies, AllRelations, OffsetConnection, FilterableRelation } from '../../src'; +import { + Relation, + PagingStrategies, + UnPagedRelation, + FilterableUnPagedRelation, + OffsetConnection, + FilterableRelation, +} from '../../src'; import { CursorConnection, FilterableCursorConnection, FilterableOffsetConnection, getRelations, - FilterableAllRelations, } from '../../src/decorators'; @ObjectType() @@ -38,12 +44,12 @@ describe('@FilterableRelation', () => { }); }); -describe('@AllRelations', () => { +describe('@UnPagedRelation', () => { it('should set the isMany flag if the relationFn returns an array', () => { const relationFn = () => TestRelation; const relationOpts = { disableRead: true }; @ObjectType() - @AllRelations('tests', relationFn, relationOpts) + @UnPagedRelation('tests', relationFn, relationOpts) class TestDTO {} const relations = getRelations(TestDTO); @@ -55,12 +61,12 @@ describe('@AllRelations', () => { }); }); -describe('@FilterableAllRelations', () => { +describe('@FilterableUnPagedRelation', () => { it('should add the relation metadata to the metadata storage', () => { const relationFn = () => TestRelation; const relationOpts = { disableRead: true }; @ObjectType() - @FilterableAllRelations('test', relationFn, relationOpts) + @FilterableUnPagedRelation('test', relationFn, relationOpts) class TestDTO {} const relations = getRelations(TestDTO); @@ -146,21 +152,21 @@ describe('getRelations', () => { @ObjectType({ isAbstract: true }) @Relation('test', () => SomeRelation) - @AllRelations('allTests', () => SomeRelation) + @UnPagedRelation('allTests', () => SomeRelation) @OffsetConnection('offsetTests', () => SomeRelation) @CursorConnection('cursorTests', () => SomeRelation) class BaseType {} @ObjectType() @Relation('implementedRelation', () => SomeRelation) - @AllRelations('implementedAllRelations', () => SomeRelation) + @UnPagedRelation('implementedAllRelations', () => SomeRelation) @OffsetConnection('implementedOffsetConnection', () => SomeRelation) @CursorConnection('implementedCursorConnection', () => SomeRelation) class ImplementingClass extends BaseType {} @ObjectType() @Relation('implementedRelation', () => SomeRelation, { relationName: 'test' }) - @AllRelations('implementedAllRelations', () => SomeRelation, { relationName: 'tests' }) + @UnPagedRelation('implementedAllRelations', () => SomeRelation, { relationName: 'tests' }) @OffsetConnection('implementedOffsetConnection', () => SomeRelation, { relationName: 'tests' }) @CursorConnection('implementedCursorConnection', () => SomeRelation, { relationName: 'testConnection' }) class DuplicateImplementor extends ImplementingClass {} diff --git a/packages/query-graphql/__tests__/resolvers/federation/__fixtures__/federation/federation-relation.resolver.graphql b/packages/query-graphql/__tests__/resolvers/federation/__fixtures__/federation/federation-relation.resolver.graphql index 4bf477da8..9342d52ea 100644 --- a/packages/query-graphql/__tests__/resolvers/federation/__fixtures__/federation/federation-relation.resolver.graphql +++ b/packages/query-graphql/__tests__/resolvers/federation/__fixtures__/federation/federation-relation.resolver.graphql @@ -8,7 +8,7 @@ type TestFederated { stringField: String! relation: TestRelationDTO! custom: TestRelationDTO! - allRelations( + unPagedRelations( """Specify to filter the records returned.""" filter: TestRelationDTOFilter = {} diff --git a/packages/query-graphql/__tests__/resolvers/federation/federation.resolver.spec.ts b/packages/query-graphql/__tests__/resolvers/federation/federation.resolver.spec.ts index 17fd4d799..cc7b2bfa5 100644 --- a/packages/query-graphql/__tests__/resolvers/federation/federation.resolver.spec.ts +++ b/packages/query-graphql/__tests__/resolvers/federation/federation.resolver.spec.ts @@ -9,7 +9,7 @@ import { OffsetConnection, OffsetQueryArgsType, Relation, - AllRelations, + UnPagedRelation, } from '../../../src'; import { expectSDL } from '../../__fixtures__'; import { createResolverFromNest, TestResolverDTO, TestService } from '../__fixtures__'; @@ -30,7 +30,7 @@ describe('FederationResolver', () => { @ObjectType('TestFederated') @Relation('relation', () => TestRelationDTO) @Relation('custom', () => TestRelationDTO, { relationName: 'other' }) - @AllRelations('allRelations', () => TestRelationDTO) + @UnPagedRelation('unPagedRelations', () => TestRelationDTO) @OffsetConnection('relationOffsetConnection', () => TestRelationDTO) @CursorConnection('relationCursorConnection', () => TestRelationDTO) class TestFederatedDTO extends TestResolverDTO { @@ -202,14 +202,14 @@ describe('FederationResolver', () => { when( mockService.queryRelations( TestRelationDTO, - 'allRelations', + 'unPagedRelations', deepEqual([dto]), objectContaining({ filter: query.filter }), ), ).thenResolve(new Map([[dto, output]])); // @ts-ignore // eslint-disable-next-line @typescript-eslint/no-unsafe-call - const result = await resolver.queryAllRelations(dto, query, {}); + const result = await resolver.queryUnPagedRelations(dto, query, {}); return expect(result).toEqual(output); }); }); diff --git a/packages/query-graphql/__tests__/types/query/filter.type.spec.ts b/packages/query-graphql/__tests__/types/query/filter.type.spec.ts index 9bdc33021..70ef44952 100644 --- a/packages/query-graphql/__tests__/types/query/filter.type.spec.ts +++ b/packages/query-graphql/__tests__/types/query/filter.type.spec.ts @@ -25,8 +25,8 @@ import { CursorConnection, FilterableCursorConnection, FilterableOffsetConnection, - AllRelations, - FilterableAllRelations, + UnPagedRelation, + FilterableUnPagedRelation, } from '../../../src'; import { expectSDL, @@ -79,8 +79,8 @@ describe('filter types', (): void => { @ObjectType('TestFilterDto') @Relation('unFilterableRelation', () => TestRelation) @FilterableRelation('filterableRelation', () => TestRelation) - @AllRelations('allRelations', () => TestRelation) - @FilterableAllRelations('filterableAllRelations', () => TestRelation) + @UnPagedRelation('unPagedRelations', () => TestRelation) + @FilterableUnPagedRelation('filterableUnPagedRelations', () => TestRelation) @OffsetConnection('unFilterableOffsetConnection', () => TestRelation) @FilterableOffsetConnection('filterableOffsetConnection', () => TestRelation) @CursorConnection('unFilterableCursorConnection', () => TestRelation) diff --git a/packages/query-graphql/src/decorators/hook.decorator.ts b/packages/query-graphql/src/decorators/hook.decorator.ts index a815ba477..d2856d2ae 100644 --- a/packages/query-graphql/src/decorators/hook.decorator.ts +++ b/packages/query-graphql/src/decorators/hook.decorator.ts @@ -42,7 +42,7 @@ export const BeforeDeleteMany = hookDecorator>(HookTyp export const BeforeQueryMany = hookDecorator>(HookTypes.BEFORE_QUERY_MANY); export const BeforeFindOne = hookDecorator(HookTypes.BEFORE_FIND_ONE); -export const getHookForType = >( +export const getHookForType = >( hookType: HookTypes, DTOClass: Class, ): HookMetaValue => getClassMetadata(DTOClass, hookMetaDataKey(hookType), true); diff --git a/packages/query-graphql/src/decorators/index.ts b/packages/query-graphql/src/decorators/index.ts index de6e1689f..e0cdf0f58 100644 --- a/packages/query-graphql/src/decorators/index.ts +++ b/packages/query-graphql/src/decorators/index.ts @@ -10,8 +10,8 @@ export { FilterableCursorConnection, OffsetConnection, FilterableOffsetConnection, - AllRelations, - FilterableAllRelations, + UnPagedRelation, + FilterableUnPagedRelation, Relation, FilterableRelation, RelationDecoratorOpts, diff --git a/packages/query-graphql/src/decorators/relation.decorator.ts b/packages/query-graphql/src/decorators/relation.decorator.ts index ef3cf07bd..753535e8a 100644 --- a/packages/query-graphql/src/decorators/relation.decorator.ts +++ b/packages/query-graphql/src/decorators/relation.decorator.ts @@ -69,8 +69,8 @@ const relationDecorator = (isMany: boolean, allowFiltering: boolean, pagingStrat export const Relation = relationDecorator(false, false); export const FilterableRelation = relationDecorator(false, true); -export const AllRelations = relationDecorator(true, false, PagingStrategies.NONE); -export const FilterableAllRelations = relationDecorator(true, true, PagingStrategies.NONE); +export const UnPagedRelation = relationDecorator(true, false, PagingStrategies.NONE); +export const FilterableUnPagedRelation = relationDecorator(true, true, PagingStrategies.NONE); export const OffsetConnection = relationDecorator(true, false, PagingStrategies.OFFSET); export const FilterableOffsetConnection = relationDecorator(true, true, PagingStrategies.OFFSET); diff --git a/packages/query-graphql/src/index.ts b/packages/query-graphql/src/index.ts index 5dee8937d..47e48b11e 100644 --- a/packages/query-graphql/src/index.ts +++ b/packages/query-graphql/src/index.ts @@ -9,8 +9,8 @@ export { FilterableCursorConnection, OffsetConnection, FilterableOffsetConnection, - AllRelations, - FilterableAllRelations, + UnPagedRelation, + FilterableUnPagedRelation, RelationTypeFunc, RelationDecoratorOpts, Reference, diff --git a/packages/query-graphql/src/resolvers/read.resolver.ts b/packages/query-graphql/src/resolvers/read.resolver.ts index 60ecf4c70..73878370f 100644 --- a/packages/query-graphql/src/resolvers/read.resolver.ts +++ b/packages/query-graphql/src/resolvers/read.resolver.ts @@ -26,7 +26,6 @@ import { extractConnectionOptsFromQueryArgs, getAuthFilter } from './helpers'; import { HookInterceptor } from '../interceptors'; import { HookTypes } from '../hooks'; - export type ReadResolverFromOpts< DTO, Opts extends ReadResolverOpts,