stacker.news/fragments/subs.js

65 lines
1.5 KiB
JavaScript
Raw Normal View History

2022-02-17 17:23:43 +00:00
import { gql } from '@apollo/client'
import { ITEM_FIELDS, ITEM_FULL_FIELDS } from './items'
import { COMMENTS_ITEM_EXT_FIELDS } from './comments'
2022-02-17 17:23:43 +00:00
export const SUB_FIELDS = gql`
fragment SubFields on Sub {
name
postTypes
rankingType
baseCost
}`
export const SUB = gql`
${SUB_FIELDS}
query Sub($sub: String) {
2022-02-17 17:23:43 +00:00
sub(name: $sub) {
...SubFields
}
}`
export const SUB_ITEMS = gql`
${SUB_FIELDS}
${ITEM_FIELDS}
${COMMENTS_ITEM_EXT_FIELDS}
query SubItems($sub: String, $sort: String, $cursor: String, $type: String, $name: String, $when: String, $by: String, $limit: Int, $includeComments: Boolean = false) {
2022-02-17 17:23:43 +00:00
sub(name: $sub) {
...SubFields
}
items(sub: $sub, sort: $sort, cursor: $cursor, type: $type, name: $name, when: $when, by: $by, limit: $limit) {
2022-02-17 17:23:43 +00:00
cursor
items {
...ItemFields
...CommentItemExtFields @include(if: $includeComments)
2022-07-21 22:55:05 +00:00
position
},
pins {
...ItemFields
...CommentItemExtFields @include(if: $includeComments)
2022-07-21 22:55:05 +00:00
position
2022-02-17 17:23:43 +00:00
}
}
}
`
export const SUB_SEARCH = gql`
${SUB_FIELDS}
${ITEM_FULL_FIELDS}
query SubSearch($sub: String, $q: String, $cursor: String, $sort: String, $what: String, $when: String, $from: String, $to: String) {
2022-02-17 17:23:43 +00:00
sub(name: $sub) {
...SubFields
}
search(sub: $sub, q: $q, cursor: $cursor, sort: $sort, what: $what, when: $when, from: $from, to: $to) {
2022-02-17 17:23:43 +00:00
cursor
items {
...ItemFullFields
2022-02-17 17:23:43 +00:00
searchTitle
searchText
}
}
}
`