Return error if query exceeds 255 char

This commit is contained in:
Hongbo Wu 2023-04-06 12:03:26 +08:00
parent 3d599ad7ab
commit 83cd0ac880
4 changed files with 9 additions and 0 deletions

View file

@ -2223,6 +2223,7 @@ export type SearchError = {
};
export enum SearchErrorCode {
QueryTooLong = 'QUERY_TOO_LONG',
Unauthorized = 'UNAUTHORIZED'
}

View file

@ -1623,6 +1623,7 @@ type SearchError {
}
enum SearchErrorCode {
QUERY_TOO_LONG
UNAUTHORIZED
}

View file

@ -53,6 +53,7 @@ import {
SaveArticleReadingProgressErrorCode,
SaveArticleReadingProgressSuccess,
SearchError,
SearchErrorCode,
SearchItem,
SearchSuccess,
SetBookmarkArticleError,
@ -873,6 +874,11 @@ export const searchResolver = authorized<
const startCursor = params.after || ''
const first = params.first || 10
// the query size is limited to 255 characters
if (params.query && params.query.length > 255) {
return { errorCodes: [SearchErrorCode.QueryTooLong] }
}
const searchQuery = parseSearchQuery(params.query || undefined)
analytics.track({

View file

@ -1587,6 +1587,7 @@ const schema = gql`
enum SearchErrorCode {
UNAUTHORIZED
QUERY_TOO_LONG
}
type SearchError {