0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

【NestJS/GraphQL】JSONを扱う方法

Posted at

環境

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 でのやり方

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?