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

Feature: Prisma GraphQL with import #12

Closed
rodrigooler opened this issue Mar 5, 2021 · 5 comments
Closed

Feature: Prisma GraphQL with import #12

rodrigooler opened this issue Mar 5, 2021 · 5 comments
Assignees
Labels
need-clarification question Further information is requested

Comments

@rodrigooler
Copy link

rodrigooler commented Mar 5, 2021

The idea would be to copy the way @prisma/client deals to avoid importing files generated through the plugin.

We can leave the files inside a .gitignore to avoid uploading a lot of unnecessary code and calling a module that solves this import.

Example

import {User} from '@ nestjs/prisma-graphql'

@Mutation (() => User)
async user () {}

or

import {UserGraphQL} from '@prisma/client'

@Mutation (() => UserGraphQL)
async user () {}

Rather than

import {User} from '../../../prisma/user/user.model'

@Mutation (() => User)
async user () {}

@unlight

@unlight
Copy link
Owner

unlight commented Mar 5, 2021

I'm not sure that I got your idea clearly... do you want to import all possible classes from single module entry, same as requested here #6?

If yes you can use setting reExportAll and typescript's tsconfig#paths feature.
But I do not recommend such way, the explanation is here #5

@felinto-dev
Copy link

felinto-dev commented Mar 6, 2021

In the schema.prisma file you can define where the files generated by the plugin will be saved, ok?

https://github.com/unlight/prisma-nestjs-graphql/blob/master/prisma/schema.prisma#L13

In this case, the idea would be to point to the node_modules folder of the plugin so that it was possible to do this, in the same way, that @prisma/client does:

import {User} from 'prisma-nestjs-graphql/models/user.ts'

@Mutation (() => User)
async user () {}

But to make this implementation, it is necessary to create an index.d.ts file that points to the @generated folder in the same way @prisma/client does.

PS: It is strange that @prisma/client does not need an "output" argument. I believe that the "provider" can specify a default value as well. If I followed this line of reasoning, I believe that it would not be necessary to inform the output, although I still find it interesting to have the option of defining it manually and overriding the standard.

@unlight unlight added the question Further information is requested label Mar 19, 2021
@felinto-dev
Copy link

I realize @unlight, you put the label "need-clarification". What did you don't understand exactly?

@unlight
Copy link
Owner

unlight commented Jul 30, 2021

@felinto-dev

I did not understand why combination of existing solutions with tsconfig#paths and option reexport does not work for you.
Also, there are new options emitSingle and emitCompiled where you can achieve almost same results.
output option controls target output directory, you can point it to anywhere including node_modules

@felinto-dev
Copy link

@felinto-dev

I did not understand why combination of existing solutions with tsconfig#paths and option reexport does not work for you.
Also, there are new options emitSingle and emitCompiled where you can achieve almost same results.
output option controls target output directory, you can point it to anywhere including node_modules

I didn't know I had these options or how to implement them in my specific use case.

Thanks for the feedback. I will check the documentation and apply them accordingly!

@unlight unlight closed this as completed May 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
need-clarification question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants