MichalLytek / MichalLytek/typegraphql-prisma

Prisma vs typegraphql-prisma input mismatch

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

Description

**Describe the Bug**
I have been getting these type errors on the latest typegraphql-prisma updates and can't figure out if its something to do with my setup or a library issue, so apologies in advance but I didn't know where else to ask this!

I'm using:
typescript: v4.5.2
typegraphql-prisma: v0.18.2
prisma: v3.6.0

```ts
@Query(() => Team, { nullable: true })
async team(@Args() args: FindFirstTeamArgs): Promise {
return await prisma.team.findFirst(args) // <--- Error here
}

Excessive stack depth comparing types '{ where?: TeamWhereInput | undefined; orderBy?: TeamOrderByWithRelationInput[] | undefined; cursor?: TeamWhereUniqueInput | undefined; take?: number | undefined; skip?: number | undefined; distinct?: ("id" | ... 23 more ... | "updatedAt")[] | undefined; }' and 'TeamFindFirstArgs'.

Types of property 'AND' are incompatible.
Type 'TeamWhereInput[] | undefined' is not assignable to type 'Enumerable | undefined'.
Type 'TeamWhereInput[]' is not assignable to type 'Enumerable | undefined'.
```

The excessive stack depth I'm assuming is due to the recursive nature of the TeamWhereInput, but what's also weird is i don't have that error on another project using the exact same environment, so debugging is proving very difficult! Maybe you have some ideas? Also, my server is building on Heroku but not locally, so again seems like maybe a local setup issue?

Thanks!

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reproducing the type error with TypeScript 4.5.2, typegraphql-prisma 0.18.2, and Prisma 3.6.0. Compare the generated TeamFindFirstArgs and TeamWhereInput types with the types accepted by prisma.team.findFirst, including the reported Enumerable mismatch. Done means the compatibility or setup cause is isolated and the result is documented.

Written by the indexing model from the issue text.

Assessment

Tech stack
graphql, typescript
Domain
api, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.