limit limits

This commit is contained in:
keyan 2023-11-22 10:30:43 -06:00
parent c214d6283f
commit 80d49a7e57
9 changed files with 58 additions and 15 deletions

View File

@ -17,6 +17,7 @@ import admin from './admin'
import blockHeight from './blockHeight'
import image from './image'
import { GraphQLScalarType, Kind } from 'graphql'
import { createIntScalar } from 'graphql-scalar'
const date = new GraphQLScalarType({
name: 'Date',
@ -45,5 +46,11 @@ const date = new GraphQLScalarType({
}
})
const limit = createIntScalar({
name: 'Limit',
description: 'Limit custom scalar type',
maximum: 1000
})
export default [user, item, message, wallet, lnurl, notifications, invite, sub,
upload, search, growth, rewards, referrals, price, admin, blockHeight, image, { JSONObject }, { Date: date }]
upload, search, growth, rewards, referrals, price, admin, blockHeight, image, { JSONObject }, { Date: date }, { Limit: limit }]

View File

@ -33,6 +33,7 @@ const common = gql`
scalar JSONObject
scalar Date
scalar Limit
`
export default [common, user, item, itemForward, message, wallet, lnurl, notifications, invite,

View File

@ -2,11 +2,11 @@ import { gql } from 'graphql-tag'
export default gql`
extend type Query {
items(sub: String, sort: String, type: String, cursor: String, name: String, when: String, from: String, to: String, by: String, limit: Int): Items
items(sub: String, sort: String, type: String, cursor: String, name: String, when: String, from: String, to: String, by: String, limit: Limit): Items
item(id: ID!): Item
pageTitleAndUnshorted(url: String!): TitleUnshorted
dupes(url: String!): [Item!]
related(cursor: String, title: String, id: ID, minMatch: String, limit: Int): Items
related(cursor: String, title: String, id: ID, minMatch: String, limit: Limit): Items
search(q: String, sub: String, cursor: String, what: String, sort: String, when: String, from: String, to: String): Items
auctionPosition(sub: String, id: ID, bid: Int!): Int!
itemRepetition(parentId: ID): Int!

View File

@ -7,10 +7,10 @@ export default gql`
user(name: String!): User
users: [User!]
nameAvailable(name: String!): Boolean!
topUsers(cursor: String, when: String, from: String, to: String, by: String, limit: Int): Users
topUsers(cursor: String, when: String, from: String, to: String, by: String, limit: Limit): Users
topCowboys(cursor: String): Users
searchUsers(q: String!, limit: Int, similarity: Float): [User!]!
userSuggestions(q: String, limit: Int): [User!]!
searchUsers(q: String!, limit: Limit, similarity: Float): [User!]!
userSuggestions(q: String, limit: Limit): [User!]!
hasNewNotes: Boolean!
}

View File

@ -140,7 +140,7 @@ export const ITEM_FULL = gql`
export const RELATED_ITEMS = gql`
${ITEM_FIELDS}
query Related($title: String, $id: ID, $cursor: String, $limit: Int) {
query Related($title: String, $id: ID, $cursor: String, $limit: Limit) {
related(title: $title, id: $id, cursor: $cursor, limit: $limit) {
cursor
items {
@ -152,7 +152,7 @@ export const RELATED_ITEMS = gql`
export const RELATED_ITEMS_WITH_ITEM = gql`
${ITEM_FIELDS}
query Related($title: String, $id: ID, $cursor: String, $limit: Int) {
query Related($title: String, $id: ID!, $cursor: String, $limit: Limit) {
item(id: $id) {
...ItemFields
}

View File

@ -24,7 +24,7 @@ export const SUB_ITEMS = gql`
${ITEM_FIELDS}
${COMMENTS_ITEM_EXT_FIELDS}
query SubItems($sub: String, $sort: String, $cursor: String, $type: String, $name: String, $when: String, $from: String, $to: String, $by: String, $limit: Int, $includeComments: Boolean = false) {
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) {
sub(name: $sub) {
...SubFields
}

View File

@ -128,7 +128,7 @@ gql`
export const USER_SUGGESTIONS =
gql`
query userSuggestions($q: String!, $limit: Int) {
query userSuggestions($q: String!, $limit: Limit) {
userSuggestions(q: $q, limit: $limit) {
name
}
@ -136,7 +136,7 @@ gql`
export const USER_SEARCH =
gql`
query searchUsers($q: String!, $limit: Int, $similarity: Float) {
query searchUsers($q: String!, $limit: Limit, $similarity: Float) {
searchUsers(q: $q, limit: $limit, similarity: $similarity) {
id
name
@ -173,8 +173,8 @@ export const USER_FIELDS = gql`
}`
export const TOP_USERS = gql`
query TopUsers($cursor: String, $when: String, $from: String, $to: String, $by: String, $limit: Int) {
topUsers(cursor: $cursor, when: $when, from: $from, to: $to, by: $by, limit: $limit) {
query TopUsers($cursor: String, $when: String, $from: String, $to: String, $by: String, ) {
topUsers(cursor: $cursor, when: $when, from: $from, to: $to, by: $by) {
users {
id
name
@ -244,7 +244,7 @@ export const USER_WITH_ITEMS = gql`
${USER_FIELDS}
${ITEM_FIELDS}
${COMMENTS_ITEM_EXT_FIELDS}
query UserWithItems($name: String!, $sub: String, $cursor: String, $type: String, $when: String, $from: String, $to: String, $by: String, $limit: Int, $includeComments: Boolean = false) {
query UserWithItems($name: String!, $sub: String, $cursor: String, $type: String, $when: String, $from: String, $to: String, $by: String, $limit: Limit, $includeComments: Boolean = false) {
user(name: $name) {
...UserFields
}

34
package-lock.json generated
View File

@ -33,6 +33,7 @@
"formik": "^2.4.5",
"github-slugger": "^2.0.0",
"graphql": "^16.8.1",
"graphql-scalar": "^0.1.0",
"graphql-tag": "^2.12.6",
"graphql-type-json": "^0.3.2",
"ln-service": "^57.0.1",
@ -7963,6 +7964,21 @@
"node": "^12.22.0 || ^14.16.0 || ^16.0.0 || >=17.0.0"
}
},
"node_modules/graphql-scalar": {
"version": "0.1.0",
"resolved": "https://registry.npmjs.org/graphql-scalar/-/graphql-scalar-0.1.0.tgz",
"integrity": "sha512-eSbxcelRfFTKHiWKO6LgOPY4eWwBTtr/z9Qz6kUaX7Dmxp2F766etSNEBY6bO32yxVfXL9uuiWV40HMntm1s0w==",
"dependencies": {
"tsdef": "^0.0.14"
},
"engines": {
"node": ">=8.0.0"
},
"peerDependencies": {
"graphql": "*",
"tslib": "^1.10.0"
}
},
"node_modules/graphql-tag": {
"version": "2.12.6",
"resolved": "https://registry.npmjs.org/graphql-tag/-/graphql-tag-2.12.6.tgz",
@ -14911,6 +14927,11 @@
"node": ">=4"
}
},
"node_modules/tsdef": {
"version": "0.0.14",
"resolved": "https://registry.npmjs.org/tsdef/-/tsdef-0.0.14.tgz",
"integrity": "sha512-UjMD4XKRWWFlFBfwKVQmGFT5YzW/ZaF8x6KpCDf92u9wgKeha/go3FU0e5WqDjXsCOdfiavCkfwfVHNDxRDGMA=="
},
"node_modules/tslib": {
"version": "2.6.0",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.0.tgz",
@ -22043,6 +22064,14 @@
"resolved": "https://registry.npmjs.org/graphql/-/graphql-16.8.1.tgz",
"integrity": "sha512-59LZHPdGZVh695Ud9lRzPBVTtlX9ZCV150Er2W43ro37wVof0ctenSaskPPjN7lVTIN8mSZt8PHUNKZuNQUuxw=="
},
"graphql-scalar": {
"version": "0.1.0",
"resolved": "https://registry.npmjs.org/graphql-scalar/-/graphql-scalar-0.1.0.tgz",
"integrity": "sha512-eSbxcelRfFTKHiWKO6LgOPY4eWwBTtr/z9Qz6kUaX7Dmxp2F766etSNEBY6bO32yxVfXL9uuiWV40HMntm1s0w==",
"requires": {
"tsdef": "^0.0.14"
}
},
"graphql-tag": {
"version": "2.12.6",
"resolved": "https://registry.npmjs.org/graphql-tag/-/graphql-tag-2.12.6.tgz",
@ -26862,6 +26891,11 @@
}
}
},
"tsdef": {
"version": "0.0.14",
"resolved": "https://registry.npmjs.org/tsdef/-/tsdef-0.0.14.tgz",
"integrity": "sha512-UjMD4XKRWWFlFBfwKVQmGFT5YzW/ZaF8x6KpCDf92u9wgKeha/go3FU0e5WqDjXsCOdfiavCkfwfVHNDxRDGMA=="
},
"tslib": {
"version": "2.6.0",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.0.tgz",

View File

@ -36,6 +36,7 @@
"formik": "^2.4.5",
"github-slugger": "^2.0.0",
"graphql": "^16.8.1",
"graphql-scalar": "^0.1.0",
"graphql-tag": "^2.12.6",
"graphql-type-json": "^0.3.2",
"ln-service": "^57.0.1",
@ -110,4 +111,4 @@
"eslint": "^8.51.0",
"standard": "^17.1.0"
}
}
}