Style part page
This commit is contained in:
@@ -16,6 +16,7 @@ export const schema = gql`
|
||||
type Query {
|
||||
parts: [Part!]!
|
||||
part(id: String!): Part
|
||||
partByUserAndTitle(userName: String! partTitle: String!): Part
|
||||
}
|
||||
|
||||
input CreatePartInput {
|
||||
|
||||
@@ -8,7 +8,8 @@ export const schema = gql`
|
||||
updatedAt: DateTime!
|
||||
image: String
|
||||
bio: String
|
||||
Part: [Part]!
|
||||
Parts: [Part]!
|
||||
Part(partTitle: String!): Part
|
||||
Reaction: [PartReaction]!
|
||||
Comment: [Comment]!
|
||||
}
|
||||
|
||||
@@ -11,6 +11,21 @@ export const part = ({ id }) => {
|
||||
where: { id },
|
||||
})
|
||||
}
|
||||
export const partByUserAndTitle = async ({ userName, partTitle }) => {
|
||||
const user = await db.user.findOne({
|
||||
where: {
|
||||
userName
|
||||
}
|
||||
})
|
||||
return db.part.findOne({
|
||||
where: {
|
||||
title_userId: {
|
||||
title: partTitle,
|
||||
userId: user.id,
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
export const createPart = async ({ input }) => {
|
||||
return db.part.create({
|
||||
|
||||
@@ -54,7 +54,11 @@ export const deleteUser = ({ id }) => {
|
||||
}
|
||||
|
||||
export const User = {
|
||||
Part: (_obj, { root }) => db.user.findOne({ where: { id: root.id } }).Part(),
|
||||
Parts: (_obj, { root }) => db.user.findOne({ where: { id: root.id } }).Part(),
|
||||
Part: (_obj, { root, ...rest }) => db.part.findOne({where: { title_userId: {
|
||||
title: _obj.partTitle,
|
||||
userId: root.id,
|
||||
}}}),
|
||||
Reaction: (_obj, { root }) =>
|
||||
db.user.findOne({ where: { id: root.id } }).Reaction(),
|
||||
Comment: (_obj, { root }) =>
|
||||
|
||||
Reference in New Issue
Block a user