I've npm installed graphql-type-json and the types. How do I use it in a code first approach, where JSONObject is the scalar in the example below.
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**;
}
I found this method and it worked for me. Might not be the code-first approach but I guess it would suffice until you figure it out :)
import { Field, ObjectType } from 'type-graphql';
import JSON from 'graphql-type-json';
@ObjectType()
export class YourClass {
@Field(() => JSON)
myProperty: any;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With