stacker.news/fragments/items.js

63 lines
986 B
JavaScript
Raw Normal View History

2021-04-22 22:14:32 +00:00
import { gql } from '@apollo/client'
2021-09-30 15:46:58 +00:00
import { COMMENTS } from './comments'
2021-04-22 22:14:32 +00:00
export const ITEM_FIELDS = gql`
fragment ItemFields on Item {
id
parentId
createdAt
title
url
user {
name
2021-08-10 22:59:06 +00:00
id
2021-04-22 22:14:32 +00:00
}
sats
2021-04-27 21:30:58 +00:00
boost
2021-09-10 21:13:52 +00:00
tips
meVote
meBoost
meTip
2021-04-22 22:14:32 +00:00
ncomments
2021-07-08 00:15:27 +00:00
root {
id
title
}
2021-04-22 22:14:32 +00:00
}`
2021-06-22 17:47:49 +00:00
export const MORE_ITEMS = gql`
${ITEM_FIELDS}
query MoreItems($sort: String!, $cursor: String, $userId: ID) {
moreItems(sort: $sort, cursor: $cursor, userId: $userId) {
cursor
items {
...ItemFields
}
}
} `
2021-09-30 15:46:58 +00:00
export const ITEM_FULL = id => gql`
2021-04-22 22:14:32 +00:00
${ITEM_FIELDS}
2021-09-30 15:46:58 +00:00
${COMMENTS}
2021-04-22 22:14:32 +00:00
{
2021-09-30 15:46:58 +00:00
item(id: ${id}) {
2021-04-22 22:14:32 +00:00
...ItemFields
2021-09-30 15:46:58 +00:00
text
comments {
...CommentsRecursive
}
2021-04-22 22:14:32 +00:00
}
}`
2021-04-24 21:05:07 +00:00
2021-09-30 15:46:58 +00:00
export const ITEM_WITH_COMMENTS = gql`
2021-04-24 21:05:07 +00:00
${ITEM_FIELDS}
2021-09-30 15:46:58 +00:00
${COMMENTS}
fragment ItemWithComments on Item {
2021-04-24 21:05:07 +00:00
...ItemFields
2021-09-30 15:46:58 +00:00
text
comments {
...CommentsRecursive
}
}`