Skip to content

Commit f0dfb3d

Browse files
committed
feat: Caching inheritance for apollo
1 parent 26ad667 commit f0dfb3d

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

src/pagination.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Type } from '@nestjs/common';
2-
import { Field, ObjectType } from '@nestjs/graphql';
2+
import { Directive, Field, ObjectType } from '@nestjs/graphql';
33
import { PageInfo } from './page-info.model';
44

55
interface IEdgeType<TItem> {
@@ -19,14 +19,13 @@ export function Paginated<TItem>(
1919
description: `A ${classRef.name} edge.`,
2020
})
2121
abstract class EdgeType {
22-
@Field(() => String, {
23-
description: 'A cursor for use in pagination.',
24-
})
22+
@Field(() => String, { description: 'A cursor for use in pagination.' })
2523
cursor: string;
2624

2725
@Field(() => classRef, {
2826
description: `The item at the end of ${classRef.name}Edge.`,
2927
})
28+
@Directive(`@cacheControl(inheritMaxAge: true)`)
3029
node: TItem;
3130
}
3231

@@ -37,11 +36,11 @@ export function Paginated<TItem>(
3736
})
3837
abstract class PaginatedType implements IPaginatedType<TItem> {
3938
@Field(() => [EdgeType], { nullable: true, description: 'A list of edges' })
39+
@Directive(`@cacheControl(inheritMaxAge: true)`)
4040
edges: EdgeType[];
4141

42-
@Field(() => PageInfo, {
43-
description: 'Information to aid in pagination.',
44-
})
42+
@Field(() => PageInfo, { description: 'Information to aid in pagination.' })
43+
@Directive(`@cacheControl(inheritMaxAge: true)`)
4544
pageInfo: PageInfo;
4645
}
4746
return PaginatedType as Type<IPaginatedType<TItem>>;

0 commit comments

Comments
 (0)