GraphCDN Module for Nest framework
This's a module for Nest to handle the purge api from GraphCDN.
$ npm i --save nestjs-graphcdn
app.resolver.ts
@Mutation()
@UseInterceptors(new GraphCDNPurgeInterceptor({
serviceName: "<service-name>",
purgeToken: "<token>",
}))
async upvotePost(@Args('postId') postId: number) {
...
}
If you want to set up interceptor as global, you have to follow Nest instructions here. Something like this.
app.module.ts
import { APP_INTERCEPTOR } from "@nestjs/core";
import { GraphCDNPurgeInterceptor } from "nestjs-graphcdn";
@Module({
providers: [
{
provide: APP_INTERCEPTOR,
useValue: new GraphCDNPurgeInterceptor({
serviceName: "<service-name>",
purgeToken: "<token>",
}),
},
],
})
export class ApplicationModule {}
To purge some queries you can now use the GraphCDNPurgeQuery
decorator.
app.resolver.ts
import { GraphCDNPurgeQuery } from "nestjs-graphcdn"
@Mutation()
@GraphCDNPurgeQuery(["<query-name>"])
async upvotePost(@Args('postId') postId: number) {
...
}
To purge some type you can now use the GraphCDNPurgeType
decorator.
app.resolver.ts
import { GraphCDNPurgeType } from "nestjs-graphcdn"
@Mutation()
@GraphCDNPurgeType("<type-name>", "<type-id-reference>")
async upvotePost(@Args('postId') postId: number) {
...
}