bak.
This commit is contained in:
parent
4b8bb47800
commit
e413163993
1
.vscode/settings.json
vendored
1
.vscode/settings.json
vendored
@ -8,6 +8,7 @@
|
||||
"metatype",
|
||||
"pmessage",
|
||||
"psubscribe",
|
||||
"QLJSON",
|
||||
"Repos",
|
||||
"rpop",
|
||||
"rpush"
|
||||
|
16
package-lock.json
generated
16
package-lock.json
generated
@ -26,6 +26,7 @@
|
||||
"debug": "^4.3.2",
|
||||
"graphql": "^15.6.1",
|
||||
"graphql-tools": "^8.2.0",
|
||||
"graphql-type-json": "^0.3.2",
|
||||
"highlight.js": "^11.3.1",
|
||||
"ioredis": "^4.28.0",
|
||||
"js-yaml": "^4.1.0",
|
||||
@ -7204,6 +7205,15 @@
|
||||
"node": ">=12"
|
||||
}
|
||||
},
|
||||
"node_modules/graphql-type-json": {
|
||||
"version": "0.3.2",
|
||||
"resolved": "https://npm.ivanli.cc/graphql-type-json/-/graphql-type-json-0.3.2.tgz",
|
||||
"integrity": "sha512-J+vjof74oMlCWXSvt0DOf2APEdZOCdubEvGDUAlqH//VBYcOYsGgRW7Xzorr44LvkjiuvecWc8fChxuZZbChtg==",
|
||||
"license": "MIT",
|
||||
"peerDependencies": {
|
||||
"graphql": ">=0.8.0"
|
||||
}
|
||||
},
|
||||
"node_modules/graphql-ws": {
|
||||
"version": "5.5.1",
|
||||
"resolved": "https://npm.ivanli.cc/graphql-ws/-/graphql-ws-5.5.1.tgz",
|
||||
@ -18373,6 +18383,12 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"graphql-type-json": {
|
||||
"version": "0.3.2",
|
||||
"resolved": "https://npm.ivanli.cc/graphql-type-json/-/graphql-type-json-0.3.2.tgz",
|
||||
"integrity": "sha512-J+vjof74oMlCWXSvt0DOf2APEdZOCdubEvGDUAlqH//VBYcOYsGgRW7Xzorr44LvkjiuvecWc8fChxuZZbChtg==",
|
||||
"requires": {}
|
||||
},
|
||||
"graphql-ws": {
|
||||
"version": "5.5.1",
|
||||
"resolved": "https://npm.ivanli.cc/graphql-ws/-/graphql-ws-5.5.1.tgz",
|
||||
|
@ -40,6 +40,7 @@
|
||||
"debug": "^4.3.2",
|
||||
"graphql": "^15.6.1",
|
||||
"graphql-tools": "^8.2.0",
|
||||
"graphql-type-json": "^0.3.2",
|
||||
"highlight.js": "^11.3.1",
|
||||
"ioredis": "^4.28.0",
|
||||
"js-yaml": "^4.1.0",
|
||||
|
@ -14,6 +14,7 @@ import { UpdateArticleInput } from './dto/update-article.input';
|
||||
import * as marked from 'marked';
|
||||
import highlight from 'highlight.js';
|
||||
import { AccountRole, Roles } from '@nestjs-lib/auth';
|
||||
import { ArticleHistory } from './models/article-history.model';
|
||||
|
||||
@Resolver(() => Article)
|
||||
export class ArticlesResolver {
|
||||
@ -81,4 +82,9 @@ export class ArticlesResolver {
|
||||
|
||||
return token?.text;
|
||||
}
|
||||
|
||||
@ResolveField(() => [ArticleHistory])
|
||||
async histories(@Parent() article: Article) {
|
||||
return article.histories;
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
import { ObjectType } from '@nestjs/graphql';
|
||||
import { ArticleHistory } from './../models/article-history.model';
|
||||
import { HideField, ObjectType } from '@nestjs/graphql';
|
||||
import { Column, Entity, Index } from 'typeorm';
|
||||
import { AppBaseEntity } from '../../commons/entities/app-base-entity';
|
||||
|
||||
@ -17,4 +18,8 @@ export class Article extends AppBaseEntity {
|
||||
|
||||
@Column({ type: 'varchar', array: true })
|
||||
tags: string[];
|
||||
|
||||
@HideField()
|
||||
@Column({ type: 'jsonb', default: [] })
|
||||
histories: ArticleHistory[];
|
||||
}
|
||||
|
15
src/articles/models/article-history.model.ts
Normal file
15
src/articles/models/article-history.model.ts
Normal file
@ -0,0 +1,15 @@
|
||||
import { Column } from 'typeorm';
|
||||
import { ObjectType, Field } from '@nestjs/graphql';
|
||||
import { Article } from '../entities/article.entity';
|
||||
|
||||
@ObjectType()
|
||||
export class ArticleHistory {
|
||||
@Field(() => Object)
|
||||
payload: Partial<Article>;
|
||||
|
||||
updatedAt: Date;
|
||||
|
||||
automatic: boolean;
|
||||
|
||||
published: boolean;
|
||||
}
|
@ -1,3 +1,4 @@
|
||||
import { ObjectScalar } from './scalars/object.scalar';
|
||||
import { Module } from '@nestjs/common';
|
||||
import { PasswordConverter } from './services/password-converter';
|
||||
import { PubSubModule } from './pub-sub/pub-sub.module';
|
||||
@ -5,7 +6,7 @@ import { AuthModule } from '@nestjs-lib/auth';
|
||||
|
||||
@Module({
|
||||
imports: [PubSubModule, AuthModule],
|
||||
providers: [PasswordConverter],
|
||||
providers: [PasswordConverter, ObjectScalar],
|
||||
exports: [PasswordConverter, AuthModule],
|
||||
})
|
||||
export class CommonsModule {}
|
||||
|
@ -12,7 +12,7 @@ export class AppBaseEntity {
|
||||
@PrimaryGeneratedColumn('uuid')
|
||||
id: string;
|
||||
|
||||
@CreateDateColumn()
|
||||
@CreateDateColumn({ select: false })
|
||||
createdAt: Date;
|
||||
|
||||
@UpdateDateColumn({ select: false })
|
||||
|
13
src/commons/scalars/object.scalar.ts
Normal file
13
src/commons/scalars/object.scalar.ts
Normal file
@ -0,0 +1,13 @@
|
||||
import { Scalar, CustomScalar } from '@nestjs/graphql';
|
||||
import { GraphQLJSONObject } from 'graphql-type-json';
|
||||
|
||||
@Scalar('Object', (type) => Object)
|
||||
export class ObjectScalar implements CustomScalar<number, Object> {
|
||||
description = GraphQLJSONObject.description;
|
||||
|
||||
parseValue = GraphQLJSONObject.parseValue;
|
||||
|
||||
serialize = GraphQLJSONObject.serialize;
|
||||
|
||||
parseLiteral = GraphQLJSONObject.parseLiteral;
|
||||
}
|
Loading…
Reference in New Issue
Block a user