Modelling two different post types and enable voting?

prisma

#1

My schema consists of a User, Two post types(Normal and Link) like hackernews.
what is the best way to model them. How would a vote mutation look like ??

type LinkPost {
id: ID! @unique
createdAt: DateTime!
description: String!
url: String!
postedBy: User
votes: [Vote!]!
}

type NormalPost {
id: ID! @unique
createdAt: DateTime!
title: String!
content: String!
postedBy: User
votes: [Vote!]!
}

enum PostType {
NormalPost,
LinkPost
}

type User {
id: ID! @unique
name: String!
email: String! @unique
password: String!
posts: [PostType!]!
votes: [Vote!]!
}

type Vote {
id: ID! @unique
postType: PostType
user: User!
}


#2

This topic was automatically closed 45 days after the last reply. New replies are no longer allowed.