環境
Code first でのやり方
インストール
yarn add graphql-type-json
yarn add -D @types/graphql-type-json
設定
import graphqlTypeJson from 'graphql-type-json'
import { Field, ObjectType } from '@nestjs/graphql'
@ObjectType()
export class SomeClass {
@Field(() => graphqlTypeJson, { nullable: true })
json?: object
}
確認
schemal.gql
ファイルに以下のエントリーが追加されていることを確認。
type SomeClass {
json: JSON
}
"""
The `JSON` scalar type represents JSON values as specified by [ECMA-404](http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-404.pdf).
"""
scalar JSON
Schema first でのやり方