import { gql } from 'apollo-server'
export default gql`
type Query {
seePhotoComments(id: Int!): [Comment]
}
`
export default {
Query: {
seePhotoComments: (_, { id }) =>
prisma.comment.findMany({
where: { photoId: id },
orderBy: {
createdAt: 'asc',
},
}),
},
}
-------------------2가지 방법 다 가능하나 나중에 pagination을 구현하기 위해서는 위의 방법을 사용해야 함.
-------------------참고로 photo folder에 만들어진 것임.
// export default {
// Query: {
// seePhotoComments: (_, { id }) =>
// prisma.photo
// .findUnique({
// where: { id },
// })
// .Comment(),
// },
// }