zen
zen copied to clipboard
Prisma one-to-many relation: Error: Unknown type
I've tried a lot of combinations for Angular with Node but this is the most awesome starter :)), nice job.
ISSUE
When I update schema.prisma by adding simple one-to-many relation
model User {
id Int @id @default(autoincrement())
createdAt DateTime @default(now())
username String @unique
password String
email String @unique
roles Role[]
products Product[]
}
model Product {
id Int @id @default(autoincrement())
owner User @relation(fields: [ownerId], references: [id])
ownerId Int
}
And after npm run prisma:migrate it is possible to insert data with Prisma Studio but it is not possible to start Node.js backend with npm run start:api.
Interface ProductUpdateManyMutationInput is not generated (file: resolversTypes.ts).

$ npm run start:api
> [email protected] start:api
> concurrently "ng serve api" "gulp handlebars:copy" "gulp handlebars:watch"
[0]
[0] > nx run api:serve
[0]
[2] [13:00:01] Using gulpfile ~/git/stepanic/angular-nest-prisma-graphql-demo/gulpfile.js
[1] [13:00:01] Using gulpfile ~/git/stepanic/angular-nest-prisma-graphql-demo/gulpfile.js
[2] [13:00:01] Starting 'handlebars:watch'...
[1] [13:00:01] Starting 'handlebars:copy'...
[1] [13:00:01] Finished 'handlebars:copy' after 36 ms
[1] gulp handlebars:copy exited with code 0
[0] chunk (runtime: main) main.js (main) 59.6 KiB (javascript) 937 bytes (runtime) [entry] [rendered]
[0]
[0] WARNING in ./apps/api/src/app/auth/index.ts 2:0-45
[0] export 'RequestUser' (reexported as 'RequestUser') was not found in './request-user' (module has no exports)
[0]
[0] WARNING in ./apps/api/src/app/graphql/models/index.ts 1:0-37
[0] export 'IContext' (reexported as 'IContext') was not found in './context' (module has no exports)
[0]
[0] webpack compiled with 2 warnings (c1b573c333bb0c74)
[0] Debugger listening on ws://localhost:9229/8cfbe261-8f68-4f5d-b827-f2de74de6fd5
[0] Debugger listening on ws://localhost:9229/8cfbe261-8f68-4f5d-b827-f2de74de6fd5
[0] For help, see: https://nodejs.org/en/docs/inspector
[0] Issues checking in progress...
[0]
[0] /Users/stepanic/git/stepanic/angular-nest-prisma-graphql-demo/node_modules/graphql/validation/validate.js:107
[0] throw new Error(errors.map(function (error) {
[0] ^
[0] Error: Unknown type "ProductUpdateManyMutationInput". Did you mean "UserUpdateManyMutationInput", "ProductUpdateManyWithoutOwnerInput", "ProductCreateManyInput", "ProductCreateManyOwnerInput", or "ProductUpdateInput"?
[0] at assertValidSDL (/Users/stepanic/git/stepanic/angular-nest-prisma-graphql-demo/node_modules/graphql/validation/validate.js:107:11)
[0] at Object.buildASTSchema (/Users/stepanic/git/stepanic/angular-nest-prisma-graphql-demo/node_modules/graphql/utilities/buildASTSchema.js:45:34)
[0] at makeExecutableSchema (/Users/stepanic/git/stepanic/angular-nest-prisma-graphql-demo/node_modules/@graphql-tools/schema/index.js:497:26)
[0] at Object../apps/api/src/app/graphql/resolvers/index.ts (/Users/stepanic/git/stepanic/angular-nest-prisma-graphql-demo/dist/apps/api/webpack:/zen/apps/api/src/app/graphql/resolvers/index.ts:17:51)
[0] at __webpack_require__ (/Users/stepanic/git/stepanic/angular-nest-prisma-graphql-demo/dist/apps/api/webpack:/zen/webpack/bootstrap:19:1)
[0] at Object../apps/api/src/app/graphql/gql-config.service.ts (/Users/stepanic/git/stepanic/angular-nest-prisma-graphql-demo/dist/apps/api/main.js:934:68)
[0] at __webpack_require__ (/Users/stepanic/git/stepanic/angular-nest-prisma-graphql-demo/dist/apps/api/webpack:/zen/webpack/bootstrap:19:1)
[0] at Object../apps/api/src/app/graphql/zen-graphql.module.ts (/Users/stepanic/git/stepanic/angular-nest-prisma-graphql-demo/dist/apps/api/main.js:2050:77)
[0] at __webpack_require__ (/Users/stepanic/git/stepanic/angular-nest-prisma-graphql-demo/dist/apps/api/webpack:/zen/webpack/bootstrap:19:1)
[0] at Object../apps/api/src/app/graphql/index.ts (/Users/stepanic/git/stepanic/angular-nest-prisma-graphql-demo/dist/apps/api/main.js:999:77)
[0] ERROR in apps/api/src/app/graphql/resolversTypes.ts:443:9
[0] TS2304: Cannot find name 'ProductUpdateManyMutationInput'.
[0] 441 |
[0] 442 | export interface UpdateManyProductArgs {
[0] > 443 | data: ProductUpdateManyMutationInput;
[0] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[0] 444 | where?: ProductWhereInput;
[0] 445 | }
[0] 446 |
[0]
^C[2] gulp handlebars:watch exited with code SIGINT
[0] ng serve api exited with code 0
Hello @stepanic. ✨ Thank you for the complements. The project has come a long way. Also, yes you are right. Something seems to be broken right now with the Pal.js code generation. I have been upgrading the dependencies for this repo at a fairly rapid pace as of late. I was trying to get the repo working with the latest versions for this particular technology stack. Pal.js and Prisma versions can sometimes have discrepancies and have been notoriously finicky about breaking changes to the Prisma DMMF as new features within Prisma have been integrated in newer versions. Sometimes it takes some effort to get Pal.js and Prisma to gel well again. I have had hiccups before where some things would break due to advancing Prisma to a newer version. It seems to have happened again. It happens! ⛩
🎐 Thanks for the heads up! Let me regress the semantic version numbers until things are at least in working order again. I'll freeze the version numbers within the package.json and block there until more compatible future updates come out. I'll be working on the issue now and inform you when things are back in working order. Cheers! 🥂
Related: https://github.com/paljs/prisma-tools/issues/252
Hello @AhmedElywa! 🎎
Pal.js apollo SDL first code generation does not seem to be working with a very simple one-to-many schema. I have created a bare minimum reproduction of this Pal.js bug for you by cloning your prisma-tools/packages/create/examples/apollo-sdl-first example and modifying the
schema.prismafile.My system:
- Windows 10
- Node v16.13.2
- [email protected]
- @paljs/[email protected]
- @paljs/[email protected]
model User { id Int @id @default(autoincrement()) username String @unique password String products Product[] } model Product { id Int @id @default(autoincrement()) owner User @relation(fields: [ownerId], references: [id]) ownerId Int }Notice how the definition for
ProductUpdateManyMutationInputis not being generated. src/resolversTypes.ts#L482-L485/* export interface ProductUpdateManyMutationInput { ... missing ... } */ export interface UpdateManyProductArgs { data: ProductUpdateManyMutationInput where?: ProductWhereInput }Though
UserUpdateManyMutationInputis being properly generated.export interface UpdateManyUserArgs { data: UserUpdateManyMutationInput where?: UserWhereInput }src/resolversTypes.ts#L605-L608
export interface UserUpdateManyMutationInput { username?: StringFieldUpdateOperationsInput password?: StringFieldUpdateOperationsInput }Would you happen to know what is happening? Thanks 🎐