How to use sequelize-typescript for querying relative objects through custom Apollo GraphQL type? I have the following query without typescript:
User and Event GraphQL types:
type User {
id: Int
login: String
email: String
role: Roles
url_identity: String
}
type Event {
id: Int
event_name: String
user: User
}
User model
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
}
Resolver:
static resolver() {
return {
Event: {
user: event => event.$get('user')
}
}
Typescript can't see event.$get('user')
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…