LoginSignup
0
3

More than 3 years have passed since last update.

Nest.js×TypeGraphQLのresolver.tsで引数を扱う注意点

Posted at

editorの自動補完を信じてはいけない

例えば以下のように
- @nestjs/graphql
- type-graphql
からmoduleを読み込む場合
- Args
- Resolver
- Query
はどちらのmoduleからもimportできます。
開発で使用するeditorによっては、自動補完で適切でないmoduleからimportされる場合があります。

import元がややこしい

Nest.js×GraphQLの時もそうですが、Resolver, Queryはnest側のmoduleになります。
ObjectType, Field, ArgsType, ID, Args等の直接、型定義に関わるmoduleはtype-graphql側からimportする必要があります。


import { Resolver, Query } from "@nestjs/graphql";
import { ObjectType, Field, ArgsType, ID, Args } from 'type-graphql'
0
3
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
3