Service / SDL generation is broken when using relations
See original GitHub issueI’m noticing when you have a relation column that has a different name then the Table it is referring to you get an error like this:
✖ Generating SDL files...
→ No schema definition found for `Author` in schema.prisma file
No schema definition found for `Author` in schema.prisma file
This happens when you for example have two tables, Post and User, and you name the user relation different on Post like this:
model Post {
id Int @id @default(autoincrement())
title String
author User @relation(fields: [authorId], references: [id])
authorId Int
}
model User {
id Int @id @default(autoincrement())
posts Post[]
}
To make it easier to reproduce you can use this repo/branch: https://github.com/jvanbaarsen/rw-examples
It happens when you run: yarn rw g sdl post
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:6 (6 by maintainers)
Top Results From Across the Web
Separate generated services and SDL files from custom ones
Maybe it's when I generate service on it's own separately from SDL (not sure) or there are “errors” in SDL(?). I just now...
Read more >Full article: Towards a service-led relationship in project-based firms
The findings show that the uniqueness and dynamics of projects necessitate the adoption of both SDL and RM, a view that is entitled...
Read more >Modeling Web Services with UML
What is a Web Service? • Represents a specific business function. • Exposed by a company. • Usually through an Internet connection.
Read more >SdL - River Thames Conditions - Environment Agency - GOV.UK
Cars garages in cornwall, Broyhill chairside table with usb? ... Nerd world media, 60k service cost, Salmo do dia 22 de outubro 2013,...
Read more >(PDF) Service-dominant logic and the business model concept
Companies are recently affected by an ongoing change of customer behaviour. Customers are no longer solely interested in product offerings ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
HMMMM
The error is coming from here: https://github.com/redwoodjs/redwood/blob/main/packages/cli/src/lib/index.js#L35-L64 But the code that calls that is this line I’m guessing: https://github.com/redwoodjs/redwood/blob/main/packages/cli/src/commands/generate/sdl/sdl.js#L112 Which specifically tries to look it up by
field.type
, which would beUser
orThingOne
, which is correct. hmmmmmmmmmI’ve run into the same issue. Oddly, I can get it to work in some circumstances but not in othes:
This does not work
This does work
The diff, if it helps:
I’ve put up a repo demoing this issue. I’ve tagged the commit where it does not work as
broken
and the commit where it does work asworks
. The way to test it:git checkout broken && yarn rw g sdl -f ThingTwo
should give you an error:I don’t know what significance there is in the difference between each model. But it’s weird that one works, the other doesn’t, and unless I’m staring past it the only thing that has changed is the name of the fields?