MichalLytek / MichalLytek/typegraphql-prisma
Errors about accessing inputs before initialization
- Dominant language
- TypeScript
- Stars
- 918
- Forks
- 130
- PR merge metrics
- No merged PRs in 30d
Description
> _Originally posted by @j718 in https://github.com/MichalLytek/typegraphql-prisma/issues/1#issuecomment-697454730_
```
"type-graphql": "^1.0.0",
typegraphql-prisma": "^0.6.1",
```
I keep getting errors about accessing inputs before initialization and wanted to get your input. The error is as follows:
```
ReferenceError: Cannot access 'BankAccountWhereInput' before initialization
at Module.BankAccountWhereInput (C:\Users\jacob\OneDrive\Documents\GitHub\tictactoe\.next\server\pages\api\graphql.js:11490:113)
at Module../src/prisma/generated/type-graphql/resolvers/inputs/BankAccountListRelationFilter.ts (C:\Users\jacob\OneDrive\Documents\GitHub\tictactoe\.next\server\pages\api\graphql.js:10345:110)
at __webpack_require__ (C:\Users\jacob\OneDrive\Documents\GitHub\tictactoe\.next\server\pages\api\graphql.js:23:31)
at Module../src/prisma/generated/type-graphql/resolvers/inputs/BankConnectionWhereInput.ts (C:\Users\jacob\OneDrive\Documents\GitHub\tictactoe\.next\server\pages\api\graphql.js:13159:95)
at __webpack_require__ (C:\Users\jacob\OneDrive\Documents\GitHub\tictactoe\.next\server\pages\api\graphql.js:23:31)
at Module../src/prisma/generated/type-graphql/resolvers/inputs/BankAccountWhereInput.ts (C:\Users\jacob\OneDrive\Documents\GitHub\tictactoe\.next\server\pages\api\graphql.js:11499:90)
at __webpack_require__ (C:\Users\jacob\OneDrive\Documents\GitHub\tictactoe\.next\server\pages\api\graphql.js:23:31)
at Module../src/prisma/generated/type-graphql/resolvers/crud/BankAccount/args/AggregateBankAccountArgs.ts (C:\Users\jacob\OneDrive\Documents\GitHub\tictactoe\.next\server\pages\api\graphql.js:3695:87)
at __webpack_require__ (C:\Users\jacob\OneDrive\Documents\GitHub\tictactoe\.next\server\pages\api\graphql.js:23:31)
at Module../src/prisma/generated/type-graphql/resolvers/crud/BankAccount/BankAccountCrudResolver.ts (C:\Users\jacob\OneDrive\Documents\GitHub\tictactoe\.next\server\pages\api\graphql.js:3208:88)
```
I have the following schema.prisma file.
```
generator client {
provider = "prisma-client-js"
}
generator typegraphql {
provider = "node ../node_modules/typegraphql-prisma/generator.js"
output = "../prisma/generated/type-graphql"
}
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
model Account {
id Int @default(autoincrement()) @id
compoundId String @unique @map(name: "compound_id")
userId Int @map(name: "user_id")
providerType String @map(name: "provider_type")
providerId String @map(name: "provider_id")
providerAccountId String @map(name: "provider_account_id")
refreshToken String? @map(name: "refresh_token")
accessToken String? @map(name: "access_token")
accessTokenExpires DateTime? @map(name: "access_token_expires")
createdAt DateTime @default(now()) @map(name: "created_at")
updatedAt DateTime @default(now()) @map(name: "updated_at")
@@index([providerAccountId], name: "providerAccountId")
@@index([providerId], name: "providerId")
@@index([userId], name: "userId")
@@map(name: "accounts")
}
model BankAccount {
account_id String @id
bankConnectionId Int @map(name: "bank_connection_id")
balancesAvailable Float @map(name: "balances_available")
balancesCurrent Float @map(name: "balances_current")
isoCurrencyCode String @map(name: "iso_currency_code")
name String
officialName String @map(name: "official_name")
subtype String
type String
bankConnection BankConnection @relation(fields: [bankConnectionId], references: [id])
@@map(name: "bank_account")
}
model BankConnection {
id Int @default(autoincrement()) @id
user User @relation(fields: [userId], references: [id])
userId Int @map(name: "user_id")
itemId String @map(name: "item_id")
accessToken String @map(name: "access_token")
bankAccounts BankAccount[]
@@map(name: "bank_connection")
}
model Session {
id Int @default(autoincrement()) @id
userId Int @map(name: "user_id")
expires DateTime
sessionToken String @unique @map(name: "session_token")
accessToken String @unique @map(name: "access_token")
createdAt DateTime @default(now()) @map(name: "created_at")
updatedAt DateTime @default(now()) @map(name: "updated_at")
user User @relation(fields: [userId], references: [id])
@@map(name: "sessions")
}
model User {
id Int @default(autoincrement()) @id
name String?
email String? @unique
emailVerified DateTime? @map(name: "email_verified")
image String?
createdAt DateTime @default(now()) @map(name: "created_at")
updatedAt DateTime @default(now()) @map(name: "updated_at")
bankConnections BankConnection[]
sessions Session[]
@@map(name: "users")
}
model VerificationRequest {
id Int @default(autoincrement()) @id
identifier String
token String @unique
expires DateTime
createdAt DateTime @default(now()) @map(name: "created_at")
updatedAt DateTime @default(now()) @map(name: "updated_at")
@@map(name: "verification_requests")
}
```
Here is my build schema command
```
const schema = await buildSchema({
// resolvers: [CreateLinkTokenResolver, UserCrudResolver, GameCrudResolver, UserRelationsResolver, GameRelationsResolver],
resolvers: [LinkTokenResolver, UserRelationsResolver ],
authChecker: customAuthChecker,
validate: false,
})
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Reproduce the failure from the schema.prisma models and the buildSchema entry point, then inspect the generated files named in the stack trace, especially BankAccountWhereInput.ts, BankAccountListRelationFilter.ts, and BankConnectionWhereInput.ts. Confirm whether the generated resolver inputs can load without the ReferenceError and verify the result through the reported Next.js GraphQL build path.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- graphql, postgresql, typescript
- Domain
- api, backend, database
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100