nexus-plugin-prisma
nexus-plugin-prisma copied to clipboard
unable to access relations
given the following schema:
model User {
id Int @id @default(autoincrement())
email String
name String
uid String
groups GroupMembership[]
created_at DateTime @default(now())
updated_at DateTime @default(now())
instances ObjectInstance[]
status Int
accounts UserAccount[]
admin_accounts Account[]
@@unique([email], name: "users_email_unique")
@@index([uid], name: "users_uid_idx")
@@map("users")
}
model UserAccount {
user_id Int
user User @relation(fields: [user_id], references: [id])
account_id Int
account Account @relation(fields: [account_id], references: [id])
created_at DateTime @default(now())
updated_at DateTime @default(now())
@@id([account_id, user_id])
@@map("user_accounts")
}
model Account {
id Int @id @default(autoincrement())
admin_id Int
admin User @relation(fields: [admin_id], references: [id])
payment String
groups Group[]
created_at DateTime @default(now())
updated_at DateTime @default(now())
users UserAccount[]
@@map("accounts")
}
I have the following prisma definition:
const ObjectUser = nexus.objectType({
name: 'User',
definition(t) {
t.model.id()
t.model.name()
t.model.email()
t.model.created_at()
t.model.updated_at()
t.model.accounts()
},
})
const ObjectAccount = nexus.objectType({
name: 'Account',
definition(t) {
t.model.id()
t.model.admin()
// t.model.users()
t.model.created_at()
t.model.updated_at()
},
})
const ObjectUserAccount = nexus.objectType({
name: 'UserAccount',
definition(t) {
t.model.account_id()
// t.model.account()
t.model.created_at()
t.model.updated_at()
t.model.user_id()
t.model.user()
},
The schema looks like they are generated correctly:
type Account {
id: Int!
admin: User!
created_at: DateTime!
updated_at: DateTime!
}
type User {
id: Int!
name: String!
email: String!
created_at: DateTime!
updated_at: DateTime!
accounts(
first: Int
last: Int
before: UserAccountWhereUniqueInput
after: UserAccountWhereUniqueInput
): [UserAccount!]!
}
type UserAccount {
account_id: Int!
created_at: DateTime!
updated_at: DateTime!
user_id: Int!
user: User!
}
however, typescript complains of the following error:
here are the versions of the relevant npm packages:
"nexus-plugin-prisma": "^0.21.0",
"@nexus/schema": "^0.16.0",
"@prisma/client": "^2.8.1",
"graphql": "^15.3.0",
I am very new to this while nexus <-> prisma setup so it might be a noob mistake, would love to get pointers on how to solve that typing issue :)
I'm hitting the same issue with these versions:
"@prisma/client": "^2.14.0",
"nexus": "^1.0.0",
"nexus-plugin-prisma": "^0.28.0",
"graphql": "^15.4.0",