stacker.news/fragments/subs.js

113 lines
2.3 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
allowFreebies
2022-02-17 17:23:43 +00:00
rankingType
2023-11-21 23:32:22 +00:00
billingType
billingCost
2023-12-08 20:02:00 +00:00
billingAutoRenew
2023-11-21 23:32:22 +00:00
billedLastAt
2022-02-17 17:23:43 +00:00
baseCost
2023-11-21 23:32:22 +00:00
userId
desc
status
}`
export const SUB_FULL_FIELDS = gql`
${SUB_FIELDS}
fragment SubFullFields on Sub {
...SubFields
user {
name
id
optional {
streak
}
}
2022-02-17 17:23:43 +00:00
}`
export const SUB = gql`
${SUB_FIELDS}
query Sub($sub: String) {
2022-02-17 17:23:43 +00:00
sub(name: $sub) {
...SubFields
}
}`
2023-11-21 23:32:22 +00:00
export const SUB_FULL = gql`
${SUB_FULL_FIELDS}
query Sub($sub: String) {
sub(name: $sub) {
...SubFullFields
}
}`
export const SUBS = gql`
2022-02-17 17:23:43 +00:00
${SUB_FIELDS}
2023-11-21 23:32:22 +00:00
query Subs {
subs {
...SubFields
}
}`
export const SUB_ITEMS = gql`
${SUB_FULL_FIELDS}
2022-02-17 17:23:43 +00:00
${ITEM_FIELDS}
${COMMENTS_ITEM_EXT_FIELDS}
2023-11-22 16:30:43 +00:00
query SubItems($sub: String, $sort: String, $cursor: String, $type: String, $name: String, $when: String, $from: String, $to: String, $by: String, $limit: Limit, $includeComments: Boolean = false) {
2022-02-17 17:23:43 +00:00
sub(name: $sub) {
2023-11-21 23:32:22 +00:00
...SubFullFields
2022-02-17 17:23:43 +00:00
}
items(sub: $sub, sort: $sort, cursor: $cursor, type: $type, name: $name, when: $when, from: $from, to: $to, 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
}
}
}
`
2023-11-21 23:32:22 +00:00
export const SUB_PAY = gql`
${SUB_FULL_FIELDS}
mutation paySub($name: String!, $hash: String, $hmac: String) {
paySub(name: $name, hash: $hash, hmac: $hmac) {
...SubFullFields
}
}`