nestjs / graphql

GraphQL (TypeScript) module for Nest framework (node.js) 🍷
https://docs.nestjs.com/graphql/quick-start
MIT License
1.45k stars 392 forks source link

Feature request: Add support for get GraphQL Types from @prisma/client #1419

Closed felinto-dev closed 3 years ago

felinto-dev commented 3 years ago

I'm submitting a...


[ ] Regression 
[ ] Bug report
[x] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

When I'm using @prisma/client with @nestjs/graphql it's frustrating because I have to declare the same entity in two different places.

https://github.com/fivethree-team/nestjs-prisma-starter/blob/master/src/models/post.model.ts#L7 https://github.com/fivethree-team/nestjs-prisma-starter/blob/master/prisma/schema.prisma#L32

There are some solutions on the market that are willing to solve this problem, such as: https://www.npmjs.com/package/prisma-nestjs-graphql https://github.com/MichalLytek/typegraphql-prisma

However, it would be very interesting to have a package like:

@ nestjs / prisma-graphql

Or similar on purpose to resolve this deficiency. What do you think?

rodrigooler commented 3 years ago

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 () {}
kamilmysliwiec commented 3 years ago

We don't plan to implement/provide such a package (and this won't change in the foreseeable future) as there's currently no bandwidth for that.

If you are interested in contributing to the community/ecosystem, consider creating it on your own and sharing it with others!