MichalLytek / MichalLytek/typegraphql-prisma

SchemaWhereInput type incorrect for id fields (emitIdAsIDType = true)

Open
#461 0 comments 0 reactions 0 assignees View on GitHub
bug community
Dominant language
TypeScript
Stars
918
Forks
130
PR merge metrics
No merged PRs in 30d

Description

**Describe the Bug**
I have the `emitIdAsIDType` option enabled, but when I have a schema like the following, the generated `WhereInput` type types `id` as `StringFilter` rather than treating it as ID.

```
schema User {
id String @id @default(uuid())
}
```

![CleanShot 2024-08-09 at 9  44 06@2x](https://github.com/user-attachments/assets/98ad37bb-f359-4ebd-b280-f7f37d942824)

The same happens for WhereUniqueInput

![CleanShot 2024-08-09 at 9  49 51@2x](https://github.com/user-attachments/assets/21859788-7e50-41ef-9616-6bfb600cdd5d)

This means I have to pass ids as `String` from my GraphQL queries.

**To Reproduce**

Generate the schema I provided above.

**Expected Behavior**

The filter should allow me to send ID types, not String.

**Environment (please complete the following information):**

- OS: macOS 14.5
- Node 20.11.1
- `typegraphql-prisma` version 0.27.2
- Prisma version 5.18
- TypeScript version 5.5.3

**Additional Context**

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by generating GraphQL types from the provided User schema with emitIdAsIDType enabled, then inspect the generated SchemaWhereInput and WhereUniqueInput types. Compare the id field types with the expected GraphQL ID type; the issue is done when both filters accept ID rather than String.

Written by the indexing model from the issue text.

Assessment

Tech stack
graphql, typescript
Domain
api, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.