question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

"redwood generate" is failing for SDL and service

See original GitHub issue

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.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
cannikincommented, Mar 12, 2020

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

1reaction
chris-hailstormcommented, Mar 10, 2020

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!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Schema Loading error on Generate SDL or Scaffold ... - GitHub
Now, I want sdls and services. yarn rw g sdl Book --crud. The sdl and services do generate. ✓ Generating SDL files.
Read more >
Separate generated services and SDL files from custom ones
If there is no service Redwood (plugin) will report SERVICE_NOT_IMPLEMENTED error on that line. The service is defined as separate file in: [ ......
Read more >
An Introduction to RedwoodJS - OpenReplay Blog
You can learn more about Redwood Database Schema. Creating an SDL & Service. Now you'll create the GraphQL interface to access the Todo...
Read more >
How to start with RedwoodJS - The full guide - Daily.dev
yarn create redwood-app redwoodprj # OR npx create-redwood-app redwoodprj ... A service has its GraphQL definition in sdl.js file:.
Read more >
How to build a full-stack app in RedwoodJS - LogRocket Blog
.redwood : Contains the build of the application. api : Serves the backend ... It will generate pages, SDL, and service for the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found