Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"redwood generate" is failing for SDL and service #207

Closed
chris-hailstorm opened this issue Mar 10, 2020 · 6 comments
Closed

"redwood generate" is failing for SDL and service #207

chris-hailstorm opened this issue Mar 10, 2020 · 6 comments

Comments

@chris-hailstorm
Copy link
Contributor

chris-hailstorm commented Mar 10, 2020

SUMMARY

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.

@peterp
Copy link
Contributor

peterp commented Mar 10, 2020

Thanks again @chris-hailstorm, I'm taking a look at this.

@chris-hailstorm
Copy link
Contributor Author

I realize scaffold isn't just page + SDL + service. I think it also includes cells and components. Clearly the most desirable results is for scaffold to work in its entirety.

@thedavidprice
Copy link
Contributor

There might be more going on here @chris-hailstorm but do try upgrading the @redwoodjs packages to v0.1 https://github.com/redwoodjs/redwood/releases/tag/v0.1.0

We’ve been having a lot of challenges scaffold+sdl that were related to @prisma/sdk bugs. Again, not sure if what you found will go away as easily as upgrading, but it would help to know if you have a chance.

@peterp
Copy link
Contributor

peterp commented Mar 10, 2020

The complaint about crud is not defined is also interesting

@chris-hailstorm
Copy link
Contributor Author

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!

@cannikin
Copy link
Member

Sounds like this is good to go? Closing now, but reopen if stuff is still busted!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants