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

Allow creating schema without source files #35

Closed
efreila opened this issue Oct 15, 2022 · 5 comments
Closed

Allow creating schema without source files #35

efreila opened this issue Oct 15, 2022 · 5 comments
Labels
enhancement New feature or request

Comments

@efreila
Copy link

efreila commented Oct 15, 2022

It looks like there's currently only support for creating a Prisma schema by creating specific folders to hold mixins, models, and enums. This seems like a great approach for the typical use-case where you want to programmatically create and maintain a project's schema.prisma file.

However, my use-case is a bit different. I'm trying to parse a GraphQL schema and build up a Prisma schema string on-demand. Essentially, I want to be able to independently create Prisma models, enums, and mixins and store them in variables, from which I'll later be able to create a complete (or partial) Prisma schema string by calling toString() on all of the objects and doing string concatentation.

I tried to get this to work by importing and using functions like createModel, createMixin, etc. and calling toString() on the resulting PrismaModels, but it doesn't look like this is possible because there's a check for an existing schema object here.

Has there been any thought given to being able to support such use-cases?

@ridafkih
Copy link
Owner

@efreila I like the idea, I can start working on something of the sorts, this will likely be a major version upgrade as the typical use-case is going to need to be set-aside so this use-case can be on equal footing.

@ridafkih
Copy link
Owner

@efreila I have a POC up and running, was a lot less than I thought as this was the original functionality of schemix. Will get a PR going.

@ridafkih ridafkih added the enhancement New feature or request label Oct 15, 2022
@ridafkih
Copy link
Owner

@efreila PR is up at #36, let me know if you have any more feedback before I merge. :)

@efreila
Copy link
Author

efreila commented Oct 15, 2022

@ridafkih Thanks for opening the PR so quickly! Taking a look at it now and should have it reviewed soon.

@ridafkih
Copy link
Owner

ridafkih commented Oct 16, 2022

@efreila Released in v1.6.0! Let me know if I broke anything with my unit testing & lint configuration changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants