redwood
redwood copied to clipboard
[RFC]: Breaking down the sdl and service generation script into parts
Summary
I think the service file generation process can be separated from the sdl file generation for use cases where the api layer uses some kind of ethereal construction data from multiple tables in a non linked way.
Motivation
Working on migrating a project I built in NextJs and Golang into a Redwood project I ran into an issue where the data I send to the user is an collection of tables and that is what the primary user will interact with is this abstraction layer. The current way I can build that with the cli is to add a prisma model, run generate sdl command to get both sdl and services file generated, then delete the prisma model and begin fixing the files to setup the way I need. I think this process could be simplified
Here is the discord chat I had about this subject https://discordapp.com/channels/679514959968993311/679514959968993476/998255562758291668
Detailed proposal
I believe the way this can be achieved is having an additional script or 2 handling the generation of sdl files and the generation of services. While keeping the a single script to handle the full process so that the assumption of CRUD operations can be upheld.
Script names may have to be changed to reflect this process fully. This I ultimately leave up to the core team to decide but my suggestions would be the following
-
yarn rw g crud NameModel
-> this would handle the sdl and service as currently sdl script does currently -
yarn rw g sdl NameModel
-> this would go to prisma file and generate just a sdl file based on the data. I don't know a use case for this but saving the namespace for when a use case arise wouldn't hurt in my opinion -
yarn rw g service NameModel
-> this looks at the graphql for a NameModel.sdl file and generates service with empty functions as use case for the functions could not be assumed
Are you interested in working on this?
- [X] I'm interested in working on this
Hi @bfg-coding !
Thank you for this issue 👍🏻 , it seems to be a topic of interest and therefore it requires a proper place to have a conversation about this. Well, here we are!
Looping in @dthyresson and @Tobbe, to resume the conversation.