blitz-js / blitz-js/blitz

No attribute 'id' when creating model 'clothing'

Open
#3,080 1 comment 0 reactions 0 assignees View on GitHub
kind/bug status/ready-to-work-on
Dominant language
TypeScript
Stars
14.1k
Forks
803
PR merge metrics
No merged PRs in 30d

Description

### What is the problem?

This is my first time using Blitzjs and I am unexperienced, but I think this issue is not my fault.

The problem: When creating a model called clothing I get errors relating to clothingId. Maybe Blitz has some difficulties pluralizing or determining the form of the word?

I have tested creating a model called item (which is clearly countable), and this gives me no errors.

### Paste all your error logs here:

```
Invalid href passed to router: /clothing//edit?_clothingId=, repeated forward-slashes (//) or backslashes \ are not valid in the href

Error: The provided `as` value (/clothing/edit) is incompatible with the `href` value (/clothing/[clothingId]/edit). Read more: https://nextjs.org/docs/messages/incompatible-href-as

Argument of type '{ id: number | undefined; }' is not assignable to parameter of type 'Pick

Property 'id' does not exist on type '{ clothing: Clothing[]; nextPage: { take: number; skip: number; } | null; hasMore: boolean; count: number; }'.ts(2339)
```

### Paste all relevant code snippets here:

```
PASTE_HERE (leave the ``` marks)
```

### What are detailed steps to reproduce this?

1. blitz generate all clothing name:string
2. Run the 'prisma migrate dev'
3. blitz dev
4. Go to /clothing/new and create clothing
5. Go to /clothing/1/edit

### Run `blitz -v` and paste the output here:

```
macOS Big Sur | darwin-arm64 | Node: v17.0.1

blitz: 0.44.4 (global)
blitz: 0.44.4 (local)

Package manager: yarn
System:
OS: macOS 11.5.2
CPU: (8) arm64 Apple M1
Memory: 947.75 MB / 16.00 GB
Shell: 5.8 - /bin/zsh
Binaries:
Node: 17.0.1 - /opt/homebrew/bin/node
Yarn: 1.22.17 - /opt/homebrew/bin/yarn
npm: 8.1.0 - /opt/homebrew/bin/npm
Watchman: 2021.11.15.00 - /opt/homebrew/bin/watchman
npmPackages:
@prisma/client: 3.6.0 => 3.6.0
blitz: 0.44.4 => 0.44.4
prisma: 3.6.0 => 3.6.0
react: 18.0.0-beta-149b420f6-20211119 => 18.0.0-beta-149b420f6-20211119
react-dom: 18.0.0-alpha-5ca4b0433-20211020 => 18.0.0-alpha-5ca4b0433-20211020
typescript: 4.5.4 => 4.5.4
```

### Please include below any other applicable logs and screenshots that show your problem:

![image](https://user-images.githubusercontent.com/28003429/146644950-16c109f3-e141-4123-96c6-ac274f5c92a4.png)

Contributor guide

Open the contributing guide

Research direction

Reproduce the issue with `blitz generate all clothing name:string`, `prisma migrate dev`, and the `/clothing/new` then `/clothing/1/edit` flow. Start from the generated clothing routes and the reported router, clothingId, and ClothingFindManyArgs errors. Done means the generated clothing model can be created and edited without invalid hrefs, missing IDs, or TypeScript errors.

Written by the indexing model from the issue text.

Assessment

Tech stack
nextjs, typescript
Domain
full-stack
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 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.