如何使用sequelize-typescript通过自定义 Apollo GraphQL 类型查询相关对象?我有以下没有打字稿的查询:
用户和事件GraphQL 类型:
type User {
id: Int
login: String
email: String
role: Roles
url_identity: String
}
type Event {
id: Int
event_name: String
user: User
}
用户模型
import {HasOne, Model, Table} from "sequelize-typescript";
import Event from "./event.model";
@Table({
timestamps: false,
modelName: 'User',
})
export default class User extends Model {
@HasOne(() => Event)
event: Event
}
解析器:
static resolver() {
return {
Event: {
user: event => event.$get('user')
}
}
打字稿看不到event.$get('user')