don't be an idiot and fetch comments when we don't need them
This commit is contained in:
parent
a989140653
commit
7b0ce0c31b
|
@ -43,9 +43,6 @@ export async function getItem (parent, { id }, { models }) {
|
|||
${SELECT}
|
||||
FROM "Item"
|
||||
WHERE id = $1`, Number(id))
|
||||
if (item) {
|
||||
item.comments = comments(models, id, 'hot')
|
||||
}
|
||||
return item
|
||||
}
|
||||
|
||||
|
@ -676,6 +673,9 @@ export default {
|
|||
WHERE path <@ text2ltree(${item.path}) AND id != ${Number(item.id)}`
|
||||
return count || 0
|
||||
},
|
||||
comments: async (item, args, { models }) => {
|
||||
return comments(models, item.id, 'hot')
|
||||
},
|
||||
sats: async (item, args, { models }) => {
|
||||
const { sum: { sats } } = await models.itemAct.aggregate({
|
||||
sum: {
|
||||
|
|
|
@ -64,14 +64,10 @@ export const USER_FULL = gql`
|
|||
|
||||
export const USER_WITH_COMMENTS = gql`
|
||||
${USER_FIELDS}
|
||||
${ITEM_WITH_COMMENTS}
|
||||
${COMMENT_FIELDS}
|
||||
query UserWithComments($name: String!) {
|
||||
user(name: $name) {
|
||||
...UserFields
|
||||
bio {
|
||||
...ItemWithComments
|
||||
}
|
||||
}
|
||||
moreFlatComments(sort: "user", name: $name) {
|
||||
cursor
|
||||
|
@ -83,14 +79,10 @@ export const USER_WITH_COMMENTS = gql`
|
|||
|
||||
export const USER_WITH_POSTS = gql`
|
||||
${USER_FIELDS}
|
||||
${ITEM_WITH_COMMENTS}
|
||||
${ITEM_FIELDS}
|
||||
query UserWithPosts($name: String!) {
|
||||
user(name: $name) {
|
||||
...UserFields
|
||||
bio {
|
||||
...ItemWithComments
|
||||
}
|
||||
}
|
||||
items(sort: "user", name: $name) {
|
||||
cursor
|
||||
|
|
Loading…
Reference in New Issue