stacker.news/fragments/items.js

235 lines
3.9 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
2021-08-10 22:59:06 +00:00
id
2021-04-22 22:14:32 +00:00
}
2022-04-19 18:32:39 +00:00
fwdUser {
name
id
}
2021-04-22 22:14:32 +00:00
sats
upvotes
2021-04-27 21:30:58 +00:00
boost
2022-05-17 22:09:15 +00:00
path
2021-12-05 17:37:55 +00:00
meSats
2022-09-21 19:57:36 +00:00
meDontLike
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
2022-02-17 17:23:43 +00:00
sub {
name
baseCost
}
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
2021-07-08 00:15:27 +00:00
root {
id
title
2022-02-17 17:23:43 +00:00
sub {
name
}
2021-10-27 18:26:34 +00:00
user {
name
id
}
2021-07-08 00:15:27 +00:00
}
2021-04-22 22:14:32 +00:00
}`
2022-02-17 17:23:43 +00:00
export const ITEMS = gql`
2021-06-22 17:47:49 +00:00
${ITEM_FIELDS}
2022-12-01 22:22:13 +00:00
query items($sub: String, $sort: String, $type: String, $cursor: String, $name: String, $within: String) {
items(sub: $sub, sort: $sort, type: $type, cursor: $cursor, name: $name, within: $within) {
2021-06-22 17:47:49 +00:00
cursor
items {
...ItemFields
position
2022-01-07 16:32:31 +00:00
},
pins {
2022-10-25 21:35:32 +00:00
...ItemFields
position
}
}
}`
export const TOP_ITEMS = gql`
${ITEM_FIELDS}
2022-10-26 14:56:22 +00:00
query topItems($sort: String, $cursor: String, $when: String = "day") {
2022-10-25 21:35:32 +00:00
topItems(sort: $sort, cursor: $cursor, when: $when) {
cursor
items {
...ItemFields
position
},
pins {
2022-01-07 16:32:31 +00:00
...ItemFields
position
2021-06-22 17:47:49 +00:00
}
}
2021-10-26 20:49:37 +00:00
}`
2022-09-22 18:44:50 +00:00
export const OUTLAWED_ITEMS = gql`
${ITEM_FIELDS}
query outlawedItems($cursor: String) {
outlawedItems(cursor: $cursor) {
cursor
items {
...ItemFields
text
}
}
}`
2022-09-22 20:42:04 +00:00
export const BORDERLAND_ITEMS = gql`
${ITEM_FIELDS}
query borderlandItems($cursor: String) {
borderlandItems(cursor: $cursor) {
cursor
items {
...ItemFields
text
}
}
}`
2022-09-27 21:19:15 +00:00
export const FREEBIE_ITEMS = gql`
${ITEM_FIELDS}
query freebieItems($cursor: String) {
freebieItems(cursor: $cursor) {
cursor
items {
...ItemFields
text
}
}
}`
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`
${ITEM_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) {
...ItemFields
2022-08-18 18:15:24 +00:00
...PollFields
2021-10-26 20:49:37 +00:00
text
}
}`
2021-06-22 17:47:49 +00:00
2021-12-21 21:29:42 +00:00
export const COMMENTS_QUERY = gql`
${COMMENTS}
query Comments($id: ID!, $sort: String) {
comments(id: $id, sort: $sort) {
...CommentsRecursive
}
}
`
2021-10-26 20:49:37 +00:00
export const ITEM_FULL = gql`
2021-04-22 22:14:32 +00:00
${ITEM_FIELDS}
2022-08-18 18:15:24 +00:00
${POLL_FIELDS}
2021-09-30 15:46:58 +00:00
${COMMENTS}
2021-10-26 20:49:37 +00:00
query Item($id: ID!) {
item(id: $id) {
2021-04-22 22:14:32 +00:00
...ItemFields
prior
2022-01-07 16:32:31 +00:00
position
2021-09-30 15:46:58 +00:00
text
2022-08-18 18:15:24 +00:00
...PollFields
2021-09-30 15:46:58 +00:00
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
}
}`
2022-01-27 19:18:48 +00:00
export const ITEM_SEARCH = gql`
${ITEM_FIELDS}
2022-10-20 22:44:44 +00:00
query Search($q: String, $cursor: String, $sort: String, $what: String, $when: String) {
search(q: $q, cursor: $cursor, sort: $sort, what: $what, when: $when) {
2022-01-27 19:18:48 +00:00
cursor
items {
...ItemFields
text
2022-02-03 22:01:42 +00:00
searchTitle
searchText
2022-01-27 19:18:48 +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
}
}
}
`