stacker.news/fragments/items.js

161 lines
2.5 KiB
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
2023-01-12 23:53:09 +00:00
deletedAt
2021-04-22 22:14:32 +00:00
title
url
user {
name
2023-02-01 14:44:35 +00:00
streak
2023-05-01 21:49:47 +00:00
hideCowboyHat
2021-08-10 22:59:06 +00:00
id
2021-04-22 22:14:32 +00:00
}
fwdUserId
otsHash
2023-02-04 00:08:08 +00:00
position
2021-04-22 22:14:32 +00:00
sats
2023-07-13 03:08:32 +00:00
meAnonSats @client
2021-04-27 21:30:58 +00:00
boost
2023-01-26 16:11:55 +00:00
bounty
2023-01-26 19:09:57 +00:00
bountyPaidTo
2022-05-17 22:09:15 +00:00
path
2023-05-06 23:17:47 +00:00
upvotes
2021-12-05 17:37:55 +00:00
meSats
2022-09-21 19:57:36 +00:00
meDontLike
meBookmark
meSubscription
2022-09-22 18:44:50 +00:00
outlawed
2022-09-27 21:19:15 +00:00
freebie
2021-04-22 22:14:32 +00:00
ncomments
2022-09-01 21:06:11 +00:00
commentSats
lastCommentAt
2022-02-17 17:23:43 +00:00
maxBid
2022-09-29 20:42:33 +00:00
isJob
2022-03-07 21:50:13 +00:00
company
location
remote
2023-05-05 17:38:56 +00:00
subName
2022-07-30 13:25:46 +00:00
pollCost
2022-02-26 16:41:30 +00:00
status
2022-07-21 22:55:05 +00:00
uploadId
2021-11-27 18:01:02 +00:00
mine
2023-02-04 00:08:08 +00:00
}`
export const ITEM_FULL_FIELDS = gql`
${ITEM_FIELDS}
fragment ItemFullFields on Item {
...ItemFields
text
fwdUser {
name
streak
2023-05-01 21:49:47 +00:00
hideCowboyHat
2023-02-04 00:08:08 +00:00
id
}
2021-07-08 00:15:27 +00:00
root {
id
title
2023-02-04 00:08:08 +00:00
bounty
bountyPaidTo
2023-05-05 17:38:56 +00:00
subName
2021-10-27 18:26:34 +00:00
user {
name
2023-02-01 14:44:35 +00:00
streak
2023-05-01 21:49:47 +00:00
hideCowboyHat
2021-10-27 18:26:34 +00:00
id
}
2021-07-08 00:15:27 +00:00
}
2021-04-22 22:14:32 +00:00
}`
2023-01-22 20:17:50 +00:00
export const ITEM_OTS_FIELDS = gql`
fragment ItemOtsFields on Item {
id
title
text
url
parentOtsHash
otsHash
deletedAt
}`
export const ITEM_OTS = gql`
${ITEM_OTS_FIELDS}
query Item($id: ID!) {
item(id: $id) {
...ItemOtsFields
}
}`
2022-08-18 18:15:24 +00:00
export const POLL_FIELDS = gql`
fragment PollFields on Item {
poll {
meVoted
count
options {
id
option
count
meVoted
}
}
}`
2021-10-26 20:49:37 +00:00
export const ITEM = gql`
2023-02-04 00:08:08 +00:00
${ITEM_FULL_FIELDS}
2022-08-18 18:15:24 +00:00
${POLL_FIELDS}
2021-10-26 20:49:37 +00:00
query Item($id: ID!) {
item(id: $id) {
2023-02-04 00:08:08 +00:00
...ItemFullFields
2022-08-18 18:15:24 +00:00
...PollFields
2021-10-26 20:49:37 +00:00
}
}`
2021-06-22 17:47:49 +00:00
2021-10-26 20:49:37 +00:00
export const ITEM_FULL = gql`
2023-02-04 00:08:08 +00:00
${ITEM_FULL_FIELDS}
2022-08-18 18:15:24 +00:00
${POLL_FIELDS}
2021-09-30 15:46:58 +00:00
${COMMENTS}
2023-07-26 00:45:35 +00:00
query Item($id: ID!, $sort: String) {
2021-10-26 20:49:37 +00:00
item(id: $id) {
2023-02-04 00:08:08 +00:00
...ItemFullFields
prior
2022-08-18 18:15:24 +00:00
...PollFields
2023-07-26 00:45:35 +00:00
comments(sort: $sort) {
2021-09-30 15:46:58 +00:00
...CommentsRecursive
}
2021-04-22 22:14:32 +00:00
}
}`
2021-04-24 21:05:07 +00:00
2022-10-26 22:46:01 +00:00
export const RELATED_ITEMS = gql`
${ITEM_FIELDS}
query Related($title: String, $id: ID, $cursor: String, $limit: Int) {
related(title: $title, id: $id, cursor: $cursor, limit: $limit) {
cursor
items {
...ItemFields
}
}
}
`
export const RELATED_ITEMS_WITH_ITEM = gql`
${ITEM_FIELDS}
query Related($title: String, $id: ID, $cursor: String, $limit: Int) {
item(id: $id) {
...ItemFields
}
related(title: $title, id: $id, cursor: $cursor, limit: $limit) {
cursor
items {
...ItemFields
}
}
}
`