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

Support output attribute for the generator #105

Closed
heddendorp opened this issue Aug 1, 2021 · 15 comments · Fixed by #166
Closed

Support output attribute for the generator #105

heddendorp opened this issue Aug 1, 2021 · 15 comments · Fixed by #166
Assignees
Labels
type/feat Add a new capability or enhance an existing one

Comments

@heddendorp
Copy link
Contributor

Perceived Problem

The generator does not support the output property of other prisma generators

Ideas / Proposed Solution(s)

Read and respect the output property in the schema definition like

generator nexusPrisma {
   provider = "nexus-prisma"
   output   = "../lib/nexus"
}
@heddendorp heddendorp added the type/feat Add a new capability or enhance an existing one label Aug 1, 2021
@jasonkuhrt jasonkuhrt added the community/help-wanted Not our focus, but accepting PRs label Aug 24, 2021
@jasonkuhrt
Copy link
Contributor

This might bring significant internal complexity, I'd like to see strong use-cases for it first.

@jasonkuhrt jasonkuhrt added needs/discussion Something needs deciding, new info changes issue scope/spec, unforeseen challenges, etc. and removed community/help-wanted Not our focus, but accepting PRs labels Aug 31, 2021
@heddendorp
Copy link
Contributor Author

My use-case is a monorepo setup where I would like to keep the prisma files together and not modify the node-modules.

If this is not supposed to work, I would suggest to change the console output that indicates the new location. Right now the config does make it at least into the prisma generate console info.

@jasonkuhrt
Copy link
Contributor

jasonkuhrt commented Sep 5, 2021

If this is not supposed to work, I would suggest to change the console output that indicates the new location.

You're saying that if it cannot be controlled it should not be mentioned in the logging to the user?

My use-case is a monorepo setup where I would like to keep the prisma files together and not modify the node-modules.

So this sounds like a subjective organizing principal which is fine but it would be good to know how, without this feature, what happens in your setup? What breaks? What are the blockers?

@jasonkuhrt
Copy link
Contributor

I think a really good way to motivate this would be to start with a PR that changes the docs in such a way as to motivate this, e.g. a recipe for "if you have X problem then set output to Y".

@dimaip
Copy link

dimaip commented Sep 18, 2021

I have exactly the same usecase as @heddendorp, I want to build everything related to Prisma and Nexus once, and share it among our microservices.

@jasonkuhrt
Copy link
Contributor

@dimaip could you share more about what that looks like. How does the db for one microservice translate to another in a useful way?

@filippodossena-mozart
Copy link

@jasonkuhrt my use-case: an API that needs to access 2 different prisma schemas/clients. I don't see any solution other than having the possibility to generate the nexus-prisma files into 2 different locations. Am I wrong?

@jasonkuhrt
Copy link
Contributor

jasonkuhrt commented Sep 21, 2021

@filippodossena-mozart so you have two PSL files in your project modelling two different databases?

@dimaip
Copy link

dimaip commented Sep 21, 2021

@jasonkuhrt all microservices share the same database/schema/Prisma client in our case.
Basically it's a bunch of independent logic deployed and packaged separately, on top of existing monolith app.

@jasonkuhrt
Copy link
Contributor

@dimaip so there is one PSL file. Thus Prisma Client is being emitted into one place I assume?

@dimaip
Copy link

dimaip commented Sep 21, 2021

I don't know what's a PSL file. I have one prisma schema file, one emitted Prisma client, that's used from a bunch of different places. I've now ditch nexus-prisma and use Pal.js to connect it to Nexus, so Prisma schema is decoupled from Nexus or nexus-prisma generator, so I can share it with services that don't need Nexus at all.

@filippodossena-mozart
Copy link

@jasonkuhrt yes, 2 different prisma schema files.

@jasonkuhrt
Copy link
Contributor

@filippodossena-mozart interesting use-case, I think that seals it for me, in that case its essential.

@jasonkuhrt jasonkuhrt removed the needs/discussion Something needs deciding, new info changes issue scope/spec, unforeseen challenges, etc. label Sep 21, 2021
@filippodossena-mozart
Copy link

@jasonkuhrt as a workaround I leveraged the nohoist option of yarn.
The following is the setup that seems to be working.

In the monorepo I created 2 packages, each one containing its own PSL file and an index.ts that exports from @prisma/client and nexus-prisma:

// index.ts
export * from "@prisma/client"
export * as NexusPrisma from "nexus-prisma" // `as` is required because prisma and nexus-prisma have some exports with equal names

The trick is to use the nohoist config in the root package.json of the monorepo:

"workspaces": {
    "packages": [
      "packages/*"
    ],
    "nohoist": [
      "**/@prisma/client",
      "**/prisma",
      "**/nexus-prisma"
    ]
  },

In this way, prisma and nexus-prisma are not hoisted and they are kept separated in each of the packages created above.

In the other packages that need to access the prisma client or the code generated by nexus-prisma, I do not import them directly from @prisma/client or nexus-prisma, but I import them from the packages created above.

@jasonkuhrt jasonkuhrt pinned this issue Sep 22, 2021
@jasonkuhrt jasonkuhrt self-assigned this Dec 13, 2021
@jasonkuhrt jasonkuhrt unpinned this issue Dec 15, 2021
@rostislav-simonik-nexus-prisma-admin
Copy link
Collaborator

🎉 This issue has been resolved in version 1.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/feat Add a new capability or enhance an existing one
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants