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}
|
${SELECT}
|
||||||
FROM "Item"
|
FROM "Item"
|
||||||
WHERE id = $1`, Number(id))
|
WHERE id = $1`, Number(id))
|
||||||
if (item) {
|
|
||||||
item.comments = comments(models, id, 'hot')
|
|
||||||
}
|
|
||||||
return item
|
return item
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -676,6 +673,9 @@ export default {
|
||||||
WHERE path <@ text2ltree(${item.path}) AND id != ${Number(item.id)}`
|
WHERE path <@ text2ltree(${item.path}) AND id != ${Number(item.id)}`
|
||||||
return count || 0
|
return count || 0
|
||||||
},
|
},
|
||||||
|
comments: async (item, args, { models }) => {
|
||||||
|
return comments(models, item.id, 'hot')
|
||||||
|
},
|
||||||
sats: async (item, args, { models }) => {
|
sats: async (item, args, { models }) => {
|
||||||
const { sum: { sats } } = await models.itemAct.aggregate({
|
const { sum: { sats } } = await models.itemAct.aggregate({
|
||||||
sum: {
|
sum: {
|
||||||
|
|
|
@ -64,14 +64,10 @@ export const USER_FULL = gql`
|
||||||
|
|
||||||
export const USER_WITH_COMMENTS = gql`
|
export const USER_WITH_COMMENTS = gql`
|
||||||
${USER_FIELDS}
|
${USER_FIELDS}
|
||||||
${ITEM_WITH_COMMENTS}
|
|
||||||
${COMMENT_FIELDS}
|
${COMMENT_FIELDS}
|
||||||
query UserWithComments($name: String!) {
|
query UserWithComments($name: String!) {
|
||||||
user(name: $name) {
|
user(name: $name) {
|
||||||
...UserFields
|
...UserFields
|
||||||
bio {
|
|
||||||
...ItemWithComments
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
moreFlatComments(sort: "user", name: $name) {
|
moreFlatComments(sort: "user", name: $name) {
|
||||||
cursor
|
cursor
|
||||||
|
@ -83,14 +79,10 @@ export const USER_WITH_COMMENTS = gql`
|
||||||
|
|
||||||
export const USER_WITH_POSTS = gql`
|
export const USER_WITH_POSTS = gql`
|
||||||
${USER_FIELDS}
|
${USER_FIELDS}
|
||||||
${ITEM_WITH_COMMENTS}
|
|
||||||
${ITEM_FIELDS}
|
${ITEM_FIELDS}
|
||||||
query UserWithPosts($name: String!) {
|
query UserWithPosts($name: String!) {
|
||||||
user(name: $name) {
|
user(name: $name) {
|
||||||
...UserFields
|
...UserFields
|
||||||
bio {
|
|
||||||
...ItemWithComments
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
items(sort: "user", name: $name) {
|
items(sort: "user", name: $name) {
|
||||||
cursor
|
cursor
|
||||||
|
|
Loading…
Reference in New Issue