MichalLytek / MichalLytek/typegraphql-prisma

Encountered a JSON parsing error due to an extraneous comma in a TypeGraphQL decorator.

Open
#433 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 met this error when tried to remigrate typegraphql-schema after a while. I have been searching for this error reason for several hours until i have found i set a comma with nothing after that in
```
@TypeGraphQL.omit(input: true,)
```
doc line. I suppose it won't be hard to add a additional check for comma and prevent other users from spending a lot of time for that minor mistake.

**To Reproduce**
``` prisma
model Key {
id Int @id @default(autoincrement())
/// @TypeGraphQL.omit(input: true,)
key String @unique

@@map(name: "keys")
}
```

**Expected Behavior**
Should ignore comma or give understandable feedback about a comma with nothing after.

**Logs**
```
✔ Generated Prisma Client (v5.7.1) to .\node_modules\@prisma\client in 172ms
"undefined" is not valid JSON
```

Environment

- OS: Windows 10
- Node: 20.9.0
- typegraphql-prisma version: 2.0.0-beta.2
- Prisma version: 5.7.0
- TypeScript version: 5.1.3

Contributor guide

No contributing guide indexed for this repository

Research direction

Use the provided Prisma schema and its @TypeGraphQL.omit(input: true,) documentation as the reproducer. Trace how the decorator text is parsed during generation and where the JSON error is produced; done means the trailing comma is either ignored or produces understandable feedback instead of "undefined" is not valid JSON.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.