Skip to content

Prisma one-to-many relation: Error: Unknown type #10

@stepanic

Description

@stepanic

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).
Screenshot 2022-01-26 at 13 08 29

$ npm run start:api

> zen@2.0.2 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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions