我已经 npm 安装了 graphql-type-json 和类型。我如何在代码优先的方法中使用它,其中 JSONObject 是下面示例中的标量。
import {Field, Int, InputType} from 'type-graphql';
import {Direction, MessageType} from '../interfaces/message.interface';
@InputType()
export class MessageInput {
@Field()
readonly to: string;
@Field()
readonly type: MessageType;
@Field()
readonly direction: Direction;
@Field()
readonly body: **JSONObject**;
}
Run Code Online (Sandbox Code Playgroud)
我找到了这个方法,它对我有用。可能不是代码优先的方法,但我想在你弄清楚之前它就足够了:)
import { Field, ObjectType } from 'type-graphql';
import JSON from 'graphql-type-json';
@ObjectType()
export class YourClass {
@Field(() => JSON)
myProperty: any;
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
1555 次 |
最近记录: |