Skip to content

Duplication between prisma schema and models #446

Answered by marcjulian
Skona27 asked this question in Q&A
Discussion options

You must be logged in to vote

@Skona27 Hi, thanks 👍 I hope I can answer your question.

Yes currently the code requires duplicates between the prisma schema and the graphql schema.

  1. Database schema: schema.prisma describes the model and thus the table created for this model.
  2. GraphQL schema: user.model.ts and any other models describes the response value of your user type for your GraphQL queries

How to resolve the duplicates for now?
It is currently necessary to have duplicate code once in schema.prisma and once for your GraphQL schema.

One idea would be to implement User from prisma client for your graphql model to always keep those prisma and graphql models in sync.

import { User } from '@prisma/client'; 
import { P…

Replies: 4 comments 2 replies

Comment options

You must be logged in to vote
1 reply
@marcjulian
Comment options

Answer selected by marcjulian
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@lucassith
Comment options

Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
5 participants
Converted from issue

This discussion was converted from issue #427 on May 04, 2021 16:18.