"redwood generate" is failing for SDL and service
See original GitHub issueSUMMARY
After a successful db save
and db up
, the generate (scaffold | sdl | service)
all fail.
ENVIRONMENT
alpha-33
OBSERVATION
I added custom models to prisma.schema
like this:
model User {
id String @id @default(cuid())
//
name String
email String
wkspaces Workspace[] @relation(name: "UserAsWorkspaceMember")
wkspaces_o Workspace[] @relation(name: "UserAsWorkspaceOwner")
projects Project[] @relation(name: "UserAsProjectMember")
projects_o Project[] @relation(name: "UserAsProjectOwner")
//
createdAt DateTime @default(now())
}
model Workspace {
id String @id @default(cuid())
//
name String
owner User @relation(name: "UserAsWorkspaceOwner")
users User[] @relation(name: "UserAsWorkspaceMember")
//
createdAt DateTime @default(now())
}
model Project {
id String @id @default(cuid())
wkspace Workspace @relation(name: "WorkspaceAsProjectContainer")
//
name String
owner User @relation(name: "UserAsProjectOwner")
users User[] @relation(name: "UserAsProjectMember")
//
createdAt DateTime @default(now())
}
Then ran yarn rw db save
– no problem – and yarn rw db up
– no problem.
Attempted a “generate scaffold” run, got this error:
$ yarn rw g scaffold user
yarn run v1.21.1
$ /Users/chris/proj/aw-hammer/node_modules/.bin/rw g scaffold user
✖ Generating scaffold files...
→ For more information try --help
Adding scaffold routes...
Adding scaffold asset imports...
✨ Done in 1.42s.
Realizing “generate scaffold” is kind of a convenience wrapper for pages, SDL and services, I attempted each generate command separately:
$ yarn rw g page user
yarn run v1.21.1
$ /Users/chris/proj/aw-hammer/node_modules/.bin/rw g page user
✔ Generating page files...
✔ Writing `./web/src/pages/UserPage/UserPage.test.js`...
✔ Writing `./web/src/pages/UserPage/UserPage.js`...
✔ Updating routes file...
✨ Done in 1.23s.
$ yarn rw g sdl user
yarn run v1.21.1
$ /Users/chris/proj/aw-hammer/node_modules/.bin/rw g sdl user
✖ Generating SDL files...
→ For more information try --help
Generating service files...
✨ Done in 1.17s.
$ yarn rw g service user
yarn run v1.21.1
$ /Users/chris/proj/aw-hammer/node_modules/.bin/rw g service user
{
_: [ 'g', 'service' ],
'$0': '/Users/chris/proj/aw-hammer/node_modules/.bin/rw'
}
✖ Generating service files...
→ crud is not defined
✨ Done in 1.12s.
As you can see, the page generation succeeded; SDL and service generation failed.
SDL: no failure details shown.
Service: says “crud is not defined”.
EXPERIMENT
I took a guess the generate function could be confused about two different relations between the same pairs of objects (although that’s a normal Prisma thing to do). As an experiment, I removed the fields and relations with the “owner” variation and tried again. Same problems.
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (6 by maintainers)
Top GitHub Comments
Sounds like this is good to go? Closing now, but reopen if stuff is still busted!
generate scaffold
seems to be working in v0.1.0.I haven’t validated what it’s generating, but the gen cycle itself runs successfully.
Thanks!