Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Graphql schema generation fails when using @TypeGraphQL.omit() on Int field #247

Open
luca-rath opened this issue Feb 7, 2022 · 5 comments
Assignees
Labels
bug Something isn't working

Comments

@luca-rath
Copy link

Describe the Bug

If a prisma model contains only one single Int field which is omitted using /// @TypeGraphQL.omit(output: true, input: true), the following error occurs when generating the graphql schema:

> @ start /Users/luca/Projects/libraries/typegraphql-prisma/examples/4-nest-js
> ts-node --transpile-only ./index.ts

[Nest] 66831  - 07.02.2022, 23:17:42     LOG [NestFactory] Starting Nest application...
[Nest] 66831  - 07.02.2022, 23:17:42     LOG [InstanceLoader] AppModule dependencies initialized +39ms
[Nest] 66831  - 07.02.2022, 23:17:42   ERROR [ExceptionHandler] Some errors occurred while generating GraphQL schema:
  Input Object type PostAvgOrderByAggregateInput must define one or more fields.
,  Input Object type PostSumOrderByAggregateInput must define one or more fields.
Please check the `details` property of the error to get more detailed info.
Error: Some errors occurred while generating GraphQL schema:
  Input Object type PostAvgOrderByAggregateInput must define one or more fields.
,  Input Object type PostSumOrderByAggregateInput must define one or more fields.
Please check the `details` property of the error to get more detailed info.
    at Function.generateFromMetadata (/Users/luca/Projects/libraries/typegraphql-prisma/examples/4-nest-js/node_modules/type-graphql/dist/schema/schema-generator.js:20:23)
    at async Object.buildSchema (/Users/luca/Projects/libraries/typegraphql-prisma/examples/4-nest-js/node_modules/type-graphql/dist/utils/buildSchema.js:10:20)

To Reproduce

I have created a pull request in my fork of this repository to reproduce the bug, see luca-rath#1

Expected Behavior

There should be no error

Environment (please complete the following information):

  • OS: macOS Monterey 12.2
  • Node 14.19.0
  • typegraphql-prisma version 0.18.4
  • Prisma version 3.8.1
  • TypeScript version 4.5.5
@MichalLytek
Copy link
Owner

Model with no fields 🤔 Interesting...

@MichalLytek MichalLytek added the bug Something isn't working label Feb 8, 2022
@MichalLytek MichalLytek self-assigned this Feb 8, 2022
@luca-rath
Copy link
Author

Sorry, I expressed myself wrong ... The model contains multiple fields with types other than Int and only one single field with type Int, which is omitted using the comment

@luca-rath
Copy link
Author

luca-rath commented Feb 8, 2022

This is the schema for the Post model:

model Post {
  id        String   @default(cuid()) @id
  createdAt DateTime @default(now())
  updatedAt DateTime @updatedAt
  published Boolean
  title     String
  content   String?
  author    User?    @relation(fields: [authorId], references: [id])
  authorId  String?
  /// @TypeGraphQL.omit(output: true, input: true)
  foo       Int      @default(1)
}

@MichalLytek
Copy link
Owner

This is related to #19.

I think I need to find a way to do not emit those types and related fields somehow, as Prisma fix won't apply to the case of omitting the last field.

@Ilwel
Copy link

Ilwel commented Jan 3, 2024

any update?

i reproduce this error today, the only workarround i see is change the type to other than Int

image

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants