今天,我已经将使用NestJS构建的GraphQL API升级到了版本7。
我已将项目设置为与NestJS GraphQL Plugin with the nest-cli一起使用新的code first approach,但是在尝试映射其中一个类时遇到了以下错误:
(node:67283) UnhandledPromiseRejectionWarning: Error: Cannot determine GraphQL output type for auth
nest-cli.json
:
{
"collection": "@nestjs/schematics",
"sourceRoot": "src",
"compilerOptions": {
"tsConfigPath": "tsconfig.json",
"plugins": [
{
"name": "@nestjs/graphql/plugin",
"options": {
"typeFileNameSuffix": [".model.ts", ".args.ts", ".input.ts"]
}
}
]
}
}
这里有两个模型:login-success.model.ts
,auth.model.ts
涉及错误:
// login-success.model.ts
import { ObjectType } from '@nestjs/graphql';
import { Auth } from './auth.model';
@ObjectType()
export class LoginSuccess {
auth: Auth;
// other stuffs
}
// auth.model.ts
import { Field, Int, ObjectType } from '@nestjs/graphql';
@ObjectType()
export class Auth {
accessToken: string;
@Field(type => Int)
expiresIn: number;
}
有人遇到问题吗?映射有问题吗?