offset-limit

This commit is contained in:
tonyrewin 2022-09-14 14:05:48 +03:00
parent c3c1c9fee3
commit a6691fc426
27 changed files with 125 additions and 138 deletions

View File

@ -1,5 +1,5 @@
[0.5.1] [0.5.1]
[+] nanostores-based custom spa routing [+] nanostores-base global store
[-] Root.tsx components [-] Root.tsx components
[+] astro/solid basic hydration [+] astro/solid basic hydration

View File

@ -51,7 +51,7 @@
"@astrojs/partytown": "^1.0.0", "@astrojs/partytown": "^1.0.0",
"@astrojs/sitemap": "^1.0.0", "@astrojs/sitemap": "^1.0.0",
"@astrojs/solid-js": "^1.0.0", "@astrojs/solid-js": "^1.0.0",
"@astrojs/vercel": "^1.0.1", "@astrojs/vercel": "^2.0.0",
"@babel/core": "^7.18.13", "@babel/core": "^7.18.13",
"@graphql-codegen/cli": "^2.6.1", "@graphql-codegen/cli": "^2.6.1",
"@graphql-codegen/typescript": "^2.5.1", "@graphql-codegen/typescript": "^2.5.1",

View File

@ -9,6 +9,7 @@ import { useStore } from '@nanostores/solid'
import { session as sessionstore, signIn } from '../../stores/auth' import { session as sessionstore, signIn } from '../../stores/auth'
import { apiClient } from '../../utils/apiClient' import { apiClient } from '../../utils/apiClient'
import { useValidator } from '../../utils/validators' import { useValidator } from '../../utils/validators'
import { baseUrl } from '../../graphql/publicGraphQLClient'
type AuthMode = 'sign-in' | 'sign-up' | 'forget' | 'reset' | 'resend' | 'password' type AuthMode = 'sign-in' | 'sign-up' | 'forget' | 'reset' | 'resend' | 'password'
@ -47,8 +48,6 @@ export default (props: { code?: string; mode?: string }) => {
// 3rd party providier auth handler // 3rd party providier auth handler
const oauth = (provider: string): void => { const oauth = (provider: string): void => {
// TODO: move to config
const baseUrl = 'https://newapi.discours.io'
const popup = window.open(`${baseUrl}/oauth/${provider}`, provider, 'width=740, height=420') const popup = window.open(`${baseUrl}/oauth/${provider}`, provider, 'width=740, height=420')
popup?.focus() popup?.focus()
hideModal() hideModal()

View File

@ -1,14 +1,12 @@
import { createClient, ClientOptions, dedupExchange, fetchExchange, Exchange } from '@urql/core' import { createClient, ClientOptions, dedupExchange, fetchExchange, Exchange } from '@urql/core'
import { devtoolsExchange } from '@urql/devtools' import { devtoolsExchange } from '@urql/devtools'
import { authExchanges } from './auth' import { authExchanges } from './auth'
import { baseUrl } from './publicGraphQLClient'
const isDev = true const isDev = true
const TOKEN_LOCAL_STORAGE_KEY = 'token' const TOKEN_LOCAL_STORAGE_KEY = 'token'
//export const baseUrl = 'http://localhost:8000'
export const baseUrl = 'https://newapi.discours.io'
const exchanges: Exchange[] = [dedupExchange, ...authExchanges, fetchExchange] const exchanges: Exchange[] = [dedupExchange, ...authExchanges, fetchExchange]
if (isDev) { if (isDev) {

View File

@ -4,8 +4,8 @@ import { devtoolsExchange } from '@urql/devtools'
// FIXME actual value // FIXME actual value
const isDev = true const isDev = true
export const baseUrl = 'https://newapi.discours.io' // export const baseUrl = 'https://newapi.discours.io'
//export const baseUrl = 'http://localhost:8000' export const baseUrl = 'http://localhost:8000'
const exchanges: Exchange[] = [dedupExchange, fetchExchange] const exchanges: Exchange[] = [dedupExchange, fetchExchange]

View File

@ -1,8 +1,8 @@
import { gql } from '@urql/core' import { gql } from '@urql/core'
export default gql` export default gql`
query ReactionsByShoutQuery($slug: String!, $page: Int!, $size: Int!) { query ReactionsByShoutQuery($limit: String!, $limit: Int!, $offset: Int!) {
reactionsByShout(slug: $slug, page: $page, size: $size) { reactionsByShout(slug: $slug, limit: $limit, offset: $offset) {
id id
body body
createdAt createdAt

View File

@ -3,7 +3,7 @@ import { gql } from '@urql/core'
// WARNING: need Auth header // WARNING: need Auth header
export default gql` export default gql`
query ShoutsReactedByUserQuery($slug: String!, $page: Int!, $size: Int!) { query ShoutsReactedByUserQuery($limit: String!, $limit: Int!, $offset: Int!) {
userReactedShouts(slug: String!, page: Int!, size: Int!) { userReactedShouts(slug: String!, page: Int!, size: Int!) {
_id: slug _id: slug
title title

View File

@ -1,8 +1,8 @@
import { gql } from '@urql/core' import { gql } from '@urql/core'
export default gql` export default gql`
query ShoutsForAuthorsQuery($slugs: [String]!, $page: Int!, $size: Int!) { query ShoutsForAuthorsQuery($slugs: [String]!, $limit: Int!, $offset: Int!) {
shoutsByAuthors(slugs: $slugs, page: $page, size: $size) { shoutsByAuthors(slugs: $slugs, limit: $limit, offset: $offset) {
_id: slug _id: slug
title title
subtitle subtitle

View File

@ -1,8 +1,8 @@
import { gql } from '@urql/core' import { gql } from '@urql/core'
export default gql` export default gql`
query ShoutsForCommunitiesQuery($slugs: [String]!, $page: Int!, $size: Int!) { query ShoutsForCommunitiesQuery($slugs: [String]!, $limit: Int!, $offset: Int!) {
shoutsByCommunities(slugs: $slugs, page: $page, size: $size) { shoutsByCommunities(slugs: $slugs, limit: $limit, offset: $offset) {
_id: slug _id: slug
title title
subtitle subtitle

View File

@ -1,8 +1,8 @@
import { gql } from '@urql/core' import { gql } from '@urql/core'
export default gql` export default gql`
query ShoutsBySessionQuery($page: Int!, $size: Int!) { query ShoutsBySessionQuery($limit: Int!, $offset: Int!) {
shoutsForFeed(page: $page, size: $size) { shoutsForFeed(limit: $limit, offset: $offset) {
_id: slug _id: slug
title title
subtitle subtitle

View File

@ -1,8 +1,8 @@
import { gql } from '@urql/core' import { gql } from '@urql/core'
export default gql` export default gql`
query ShoutsForTopicsQuery($slugs: [String]!, $page: Int!, $size: Int!) { query ShoutsForTopicsQuery($slugs: [String]!, $limit: Int!, $offset: Int!) {
shoutsByTopics(slugs: $slugs, page: $page, size: $size) { shoutsByTopics(slugs: $slugs, limit: $limit, offset: $offset) {
_id: slug _id: slug
title title
subtitle subtitle

View File

@ -1,8 +1,8 @@
import { gql } from '@urql/core' import { gql } from '@urql/core'
export default gql` export default gql`
query RecentAllQuery($page: Int!, $size: Int!) { query RecentAllQuery($limit: Int!, $offset: Int!) {
recentAll(page: $page, size: $size) { recentAll(limit: $limit, offset: $offset) {
_id: slug _id: slug
title title
subtitle subtitle

View File

@ -1,8 +1,8 @@
import { gql } from '@urql/core' import { gql } from '@urql/core'
export default gql` export default gql`
query RecentPublishedQuery($page: Int!, $size: Int!) { query RecentPublishedQuery($limit: Int!, $offset: Int!) {
recentPublished(page: $page, size: $size) { recentPublished(limit: $limit, offset: $offset) {
_id: slug _id: slug
title title
subtitle subtitle

View File

@ -1,8 +1,8 @@
import { gql } from '@urql/core' import { gql } from '@urql/core'
export default gql` export default gql`
query TopMonthShoutsQuery($page: Int!, $size: Int!) { query TopMonthShoutsQuery($limit: Int!, $offset: Int!) {
topMonth(page: $page, size: $size) { topMonth(limit: $limit, offset: $offset) {
_id: slug _id: slug
title title
subtitle subtitle

View File

@ -1,8 +1,8 @@
import { gql } from '@urql/core' import { gql } from '@urql/core'
export default gql` export default gql`
query TopOverallShoutsQuery($page: Int!, $size: Int!) { query TopOverallShoutsQuery($limit: Int!, $offset: Int!) {
topOverall(page: $page, size: $size) { topOverall(limit: $limit, offset: $offset) {
_id: slug _id: slug
title title
subtitle subtitle

View File

@ -1,8 +1,8 @@
import { gql } from '@urql/core' import { gql } from '@urql/core'
export default gql` export default gql`
query TopViewedShoutsQuery($page: Int!, $size: Int!) { query TopViewedShoutsQuery($limit: Int!, $offset: Int!) {
topViewed(page: $page, size: $size) { topViewed(limit: $limit, offset: $offset) {
_id: slug _id: slug
title title
subtitle subtitle

View File

@ -1,8 +1,8 @@
import { gql } from '@urql/core' import { gql } from '@urql/core'
export default gql` export default gql`
query ReactionsByAuthorQuery($author: String!, $page: Int!, $size: Int!) { query ReactionsByAuthorQuery($author: String!, $limit: Int!, $offset: Int!) {
reactionsByAuthor(slug: $author, page: $page, size: $size) { reactionsByAuthor(slug: $author, limit: $limit, offset: $offset) {
id id
body body
createdAt createdAt

View File

@ -1,8 +1,8 @@
import { gql } from '@urql/core' import { gql } from '@urql/core'
export default gql` export default gql`
query AuthorssAllQuery($page: Int!, $size: Int!) { query AuthorssAllQuery($limit: Int!, $offset: Int!) {
authorsAll(page: $page, size: $size) { authorsAll(limit: $limit, offset: $offset) {
_id: slug _id: slug
slug slug
name name

View File

@ -1,8 +1,8 @@
import { gql } from '@urql/core' import { gql } from '@urql/core'
export default gql` export default gql`
query ReactionsForShoutsQuery($shouts: [String]!, $page: Int!, $size: Int!) { query ReactionsForShoutsQuery($shouts: [String]!, $limit: Int!, $offset: Int!) {
reactionsForShouts(shouts: $shouts, page: $page, size: $size) { reactionsForShouts(shouts: $shouts, limit: $limit, offset: $offset) {
id id
createdBy { createdBy {
slug slug

View File

@ -1,8 +1,8 @@
import { gql } from '@urql/core' import { gql } from '@urql/core'
export default gql` export default gql`
query SearchResultsQuery($q: String!, $page: Int!, $size: Int!) { query SearchResultsQuery($q: String!, $limit: Int!, $offset: Int!) {
searchQuery(q: $q, page: $page, size: $size) { searchQuery(q: $q, limit: $limit, offset: $offset) {
_id: slug _id: slug
title title
subtitle subtitle

View File

@ -371,8 +371,8 @@ export type Query = {
} }
export type QueryAuthorsAllArgs = { export type QueryAuthorsAllArgs = {
page: Scalars['Int'] limit: Scalars['Int']
size: Scalars['Int'] offset: Scalars['Int']
} }
export type QueryEnterChatArgs = { export type QueryEnterChatArgs = {
@ -386,8 +386,8 @@ export type QueryGetCommunityArgs = {
export type QueryGetMessagesArgs = { export type QueryGetMessagesArgs = {
chatId: Scalars['String'] chatId: Scalars['String']
page: Scalars['Int'] limit: Scalars['Int']
size: Scalars['Int'] offset: Scalars['Int']
} }
export type QueryGetShoutBySlugArgs = { export type QueryGetShoutBySlugArgs = {
@ -411,41 +411,41 @@ export type QueryIsEmailUsedArgs = {
} }
export type QueryMyCandidatesArgs = { export type QueryMyCandidatesArgs = {
page: Scalars['Int'] limit: Scalars['Int']
size: Scalars['Int'] offset: Scalars['Int']
} }
export type QueryReactionsByAuthorArgs = { export type QueryReactionsByAuthorArgs = {
page: Scalars['Int'] limit: Scalars['Int']
size: Scalars['Int'] offset: Scalars['Int']
slug: Scalars['String'] slug: Scalars['String']
} }
export type QueryReactionsByShoutArgs = { export type QueryReactionsByShoutArgs = {
page: Scalars['Int'] limit: Scalars['Int']
size: Scalars['Int'] offset: Scalars['Int']
slug: Scalars['String'] slug: Scalars['String']
} }
export type QueryReactionsForShoutsArgs = { export type QueryReactionsForShoutsArgs = {
page: Scalars['Int'] limit: Scalars['Int']
shouts: Array<InputMaybe<Scalars['String']>> shouts: Array<InputMaybe<Scalars['String']>>
size: Scalars['Int'] offset: Scalars['Int']
} }
export type QueryRecentAllArgs = { export type QueryRecentAllArgs = {
page: Scalars['Int'] limit: Scalars['Int']
size: Scalars['Int'] offset: Scalars['Int']
} }
export type QueryRecentPublishedArgs = { export type QueryRecentPublishedArgs = {
page: Scalars['Int'] limit: Scalars['Int']
size: Scalars['Int'] offset: Scalars['Int']
} }
export type QueryRecentReactedArgs = { export type QueryRecentReactedArgs = {
page: Scalars['Int'] limit: Scalars['Int']
size: Scalars['Int'] offset: Scalars['Int']
} }
export type QuerySearchQueryArgs = { export type QuerySearchQueryArgs = {
@ -455,8 +455,8 @@ export type QuerySearchQueryArgs = {
} }
export type QueryShoutsByAuthorsArgs = { export type QueryShoutsByAuthorsArgs = {
page: Scalars['Int'] limit: Scalars['Int']
size: Scalars['Int'] offset: Scalars['Int']
slugs: Array<InputMaybe<Scalars['String']>> slugs: Array<InputMaybe<Scalars['String']>>
} }
@ -467,20 +467,20 @@ export type QueryShoutsByCollectionArgs = {
} }
export type QueryShoutsByCommunitiesArgs = { export type QueryShoutsByCommunitiesArgs = {
page: Scalars['Int'] limit: Scalars['Int']
size: Scalars['Int'] offset: Scalars['Int']
slugs: Array<InputMaybe<Scalars['String']>> slugs: Array<InputMaybe<Scalars['String']>>
} }
export type QueryShoutsByTopicsArgs = { export type QueryShoutsByTopicsArgs = {
page: Scalars['Int'] limit: Scalars['Int']
size: Scalars['Int'] offset: Scalars['Int']
slugs: Array<InputMaybe<Scalars['String']>> slugs: Array<InputMaybe<Scalars['String']>>
} }
export type QueryShoutsForFeedArgs = { export type QueryShoutsForFeedArgs = {
page: Scalars['Int'] limit: Scalars['Int']
size: Scalars['Int'] offset: Scalars['Int']
} }
export type QuerySignInArgs = { export type QuerySignInArgs = {
@ -489,18 +489,18 @@ export type QuerySignInArgs = {
} }
export type QueryTopMonthArgs = { export type QueryTopMonthArgs = {
page: Scalars['Int'] limit: Scalars['Int']
size: Scalars['Int'] offset: Scalars['Int']
} }
export type QueryTopOverallArgs = { export type QueryTopOverallArgs = {
page: Scalars['Int'] limit: Scalars['Int']
size: Scalars['Int'] offset: Scalars['Int']
} }
export type QueryTopViewedArgs = { export type QueryTopViewedArgs = {
page: Scalars['Int'] limit: Scalars['Int']
size: Scalars['Int'] offset: Scalars['Int']
} }
export type QueryTopicsByAuthorArgs = { export type QueryTopicsByAuthorArgs = {

View File

@ -3,7 +3,7 @@ import { FeedPage } from '../../components/Views/Feed'
import Zine from '../../layouts/zine.astro' import Zine from '../../layouts/zine.astro'
import { apiClient } from '../../utils/apiClient' import { apiClient } from '../../utils/apiClient'
const recentArticles = await apiClient.getRecentArticles({ page: 1 }) const recentArticles = await apiClient.getRecentArticles({ limit: 50, offset: 0 })
const shoutSlugs = recentArticles.map((s) => s.slug) const shoutSlugs = recentArticles.map((s) => s.slug)
const reactions = await apiClient.getReactionsForShouts({ shoutSlugs }) const reactions = await apiClient.getReactionsForShouts({ shoutSlugs })
--- ---

View File

@ -4,7 +4,7 @@ import Zine from '../layouts/zine.astro'
import { apiClient } from '../utils/apiClient' import { apiClient } from '../utils/apiClient'
const randomTopics = await apiClient.getRandomTopics() const randomTopics = await apiClient.getRandomTopics()
const recentPublished = await apiClient.getRecentPublishedArticles({ page: 1 }) const recentPublished = await apiClient.getRecentPublishedArticles({ limit: 50, offset: 0 })
const topMonth = await apiClient.getTopMonthArticles() const topMonth = await apiClient.getTopMonthArticles()
const topOverall = await apiClient.getTopArticles() const topOverall = await apiClient.getTopArticles()

View File

@ -5,7 +5,7 @@ import { apiClient } from '../utils/apiClient'
const params: URLSearchParams = Astro.url.searchParams const params: URLSearchParams = Astro.url.searchParams
const q = params.get('q') const q = params.get('q')
const results = await apiClient.getSearchResults({ query: q }) const results = await apiClient.getSearchResults({ query: q, limit: 50, offset: 0 })
--- ---
<Zine> <Zine>

View File

@ -4,9 +4,9 @@ import Zine from '../../layouts/zine.astro'
import { apiClient } from '../../utils/apiClient' import { apiClient } from '../../utils/apiClient'
const slug = Astro.params.slug?.toString() || '' const slug = Astro.params.slug?.toString() || ''
const page = parseInt(Astro.params?.page as string, 10) || 1 const limit = parseInt(Astro.params?.limit as string, 10) || 50
const size = parseInt(Astro.params?.size as string, 10) || 50 const offset = parseInt(Astro.params?.offset as string, 10) || 0
const articles = await apiClient.getArticlesForTopics({ topicSlugs: [slug], page, size }) const articles = await apiClient.getArticlesForTopics({ topicSlugs: [slug], limit, offset })
const topic = articles[0].topics.find(({ slug: topicSlug }) => topicSlug === slug) const topic = articles[0].topics.find(({ slug: topicSlug }) => topicSlug === slug)
Astro.response.headers.set('Cache-Control', 's-maxage=1, stale-while-revalidate') Astro.response.headers.set('Cache-Control', 's-maxage=1, stale-while-revalidate')

View File

@ -33,31 +33,27 @@ import authorsBySlugs from '../graphql/query/authors-by-slugs'
const log = getLogger('api-client') const log = getLogger('api-client')
const DEFAULT_AUTHOR_ARTICLES_PAGE_SIZE = 50 const FEED_SIZE = 50
const DEFAULT_TOPIC_ARTICLES_PAGE_SIZE = 50 const REACTIONS_PAGE_SIZE = 100
const DEFAULT_RECENT_ARTICLES_PAGE_SIZE = 50
const DEFAULT_REACTIONS_PAGE_SIZE = 50
const DEFAULT_SEARCH_RESULTS_PAGE_SIZE = 50
const DEFAULT_PUBLISHED_ARTICLES_PAGE_SIZE = 50
const DEFAULT_RANDOM_TOPICS_AMOUNT = 12 const DEFAULT_RANDOM_TOPICS_AMOUNT = 12
export const apiClient = { export const apiClient = {
getTopArticles: async () => { getTopArticles: async () => {
const response = await publicGraphQLClient.query(articlesTopRated, { page: 1, size: 10 }).toPromise() const response = await publicGraphQLClient.query(articlesTopRated, { limit: 10, offset: 0 }).toPromise()
return response.data.topOverall return response.data.topOverall
}, },
getTopMonthArticles: async () => { getTopMonthArticles: async () => {
const response = await publicGraphQLClient.query(articlesTopMonth, { page: 1, size: 10 }).toPromise() const response = await publicGraphQLClient.query(articlesTopMonth, { limit: 10, offset: 0 }).toPromise()
return response.data.topMonth return response.data.topMonth
}, },
getRecentPublishedArticles: async ({ getRecentPublishedArticles: async ({
page = 1, limit = FEED_SIZE,
size = DEFAULT_RECENT_ARTICLES_PAGE_SIZE offset = 0
}: { }: {
page?: number limit?: number
size?: number offset?: number
}) => { }) => {
const response = await publicGraphQLClient.query(articlesRecentPublished, { page, size }).toPromise() const response = await publicGraphQLClient.query(articlesRecentPublished, { limit, offset }).toPromise()
return response.data.recentPublished return response.data.recentPublished
}, },
@ -70,34 +66,34 @@ export const apiClient = {
}, },
getSearchResults: async ({ getSearchResults: async ({
query, query,
page = 1, limit = FEED_SIZE,
size = DEFAULT_SEARCH_RESULTS_PAGE_SIZE offset = 0
}: { }: {
query: string query: string
page?: number limit: number
size?: number offset: number
}): Promise<Shout[]> => { }): Promise<Shout[]> => {
const response = await publicGraphQLClient const response = await publicGraphQLClient
.query(searchResults, { .query(searchResults, {
q: query, q: query,
page, limit,
size offset
}) })
.toPromise() .toPromise()
return response.data.searchQuery return response.data.searchQuery
}, },
getRecentArticles: async ({ getRecentArticles: async ({
page = 1, limit = FEED_SIZE,
size = DEFAULT_RECENT_ARTICLES_PAGE_SIZE offset = 0
}: { }: {
page?: number limit: number
size?: number offset: number
}): Promise<Shout[]> => { }): Promise<Shout[]> => {
const response = await publicGraphQLClient const response = await publicGraphQLClient
.query(articlesRecentAll, { .query(articlesRecentAll, {
page, limit,
size offset
}) })
.toPromise() .toPromise()
@ -105,18 +101,18 @@ export const apiClient = {
}, },
getArticlesForTopics: async ({ getArticlesForTopics: async ({
topicSlugs, topicSlugs,
page = 1, limit = FEED_SIZE,
size = DEFAULT_TOPIC_ARTICLES_PAGE_SIZE offset = 0
}: { }: {
topicSlugs: string[] topicSlugs: string[]
page?: number limit: number
size?: number offset: number
}): Promise<Shout[]> => { }): Promise<Shout[]> => {
const response = await publicGraphQLClient const response = await publicGraphQLClient
.query(articlesForTopics, { .query(articlesForTopics, {
slugs: topicSlugs, slugs: topicSlugs,
page, limit,
size offset
}) })
.toPromise() .toPromise()
@ -124,18 +120,18 @@ export const apiClient = {
}, },
getArticlesForAuthors: async ({ getArticlesForAuthors: async ({
authorSlugs, authorSlugs,
page = 1, limit = FEED_SIZE,
size = DEFAULT_AUTHOR_ARTICLES_PAGE_SIZE offset = 0
}: { }: {
authorSlugs: string[] authorSlugs: string[]
page?: number limit: number
size?: number offset: number
}): Promise<Shout[]> => { }): Promise<Shout[]> => {
const response = await publicGraphQLClient const response = await publicGraphQLClient
.query(articlesForAuthors, { .query(articlesForAuthors, {
slugs: authorSlugs, slugs: authorSlugs,
page, limit,
size offset
}) })
.toPromise() .toPromise()
@ -192,14 +188,8 @@ export const apiClient = {
const response = await privateGraphQLClient.mutation(mySession, {}).toPromise() const response = await privateGraphQLClient.mutation(mySession, {}).toPromise()
return response.data.refreshSession return response.data.refreshSession
}, },
getPublishedArticles: async ({ getPublishedArticles: async ({ limit = FEED_SIZE, offset }: { limit?: number; offset?: number }) => {
page = 1, const response = await publicGraphQLClient.query(articlesRecentPublished, { limit, offset }).toPromise()
size = DEFAULT_PUBLISHED_ARTICLES_PAGE_SIZE
}: {
page?: number
size?: number
}) => {
const response = await publicGraphQLClient.query(articlesRecentPublished, { page, size }).toPromise()
return response.data.recentPublished return response.data.recentPublished
}, },
@ -209,7 +199,7 @@ export const apiClient = {
}, },
getAllAuthors: async () => { getAllAuthors: async () => {
const response = await publicGraphQLClient.query(authorsAll, { page: 1, size: 999999 }).toPromise() const response = await publicGraphQLClient.query(authorsAll, { limit: 9999, offset: 9999 }).toPromise()
return response.data.authorsAll return response.data.authorsAll
}, },
getArticle: async ({ slug }: { slug: string }): Promise<Shout> => { getArticle: async ({ slug }: { slug: string }): Promise<Shout> => {
@ -222,18 +212,18 @@ export const apiClient = {
getReactionsForShouts: async ({ getReactionsForShouts: async ({
shoutSlugs, shoutSlugs,
page = 1, limit = FEED_SIZE,
size = DEFAULT_REACTIONS_PAGE_SIZE offset = 0
}: { }: {
shoutSlugs: string[] shoutSlugs: string[]
page?: number limit?: number
size?: number offset?: number
}): Promise<Reaction[]> => { }): Promise<Reaction[]> => {
const response = await publicGraphQLClient const response = await publicGraphQLClient
.query(reactionsForShouts, { .query(reactionsForShouts, {
shouts: shoutSlugs, shouts: shoutSlugs,
page, limit,
size offset
}) })
.toPromise() .toPromise()
@ -241,18 +231,18 @@ export const apiClient = {
}, },
getArticleReactions: async ({ getArticleReactions: async ({
articleSlug, articleSlug,
page, limit = REACTIONS_PAGE_SIZE,
size offset = 0
}: { }: {
articleSlug: string articleSlug: string
page: number limit: number
size: number offset: number
}): Promise<Reaction[]> => { }): Promise<Reaction[]> => {
const response = await publicGraphQLClient const response = await publicGraphQLClient
.query(articleReactions, { .query(articleReactions, {
slug: articleSlug, slug: articleSlug,
page, limit,
size offset
}) })
.toPromise() .toPromise()

View File

@ -182,10 +182,10 @@
node-fetch "^3.2.5" node-fetch "^3.2.5"
which-pm-runs "^1.1.0" which-pm-runs "^1.1.0"
"@astrojs/vercel@^1.0.1": "@astrojs/vercel@^2.0.0":
version "1.0.2" version "2.0.0"
resolved "https://registry.yarnpkg.com/@astrojs/vercel/-/vercel-1.0.2.tgz#b05b9ce7c98b113b7461e4e7588318e88801e0f2" resolved "https://registry.yarnpkg.com/@astrojs/vercel/-/vercel-2.0.0.tgz#4a9d750bd0784858a0acd073a8794df3d1a40fc9"
integrity sha512-IdEkJQVZ9iBVCrojVHbwoFWJ4uF4SBo0GuC4vMDL+wuZPnjV6TnZZDJwl77HwylFqbqujjmm4pvqhHJAQ8GTFA== integrity sha512-KUg2PAJO/hNXx3DYPwORrzSiTgFucQwaNePjTXly58xlbYkZIppspgKuCPA2+vpmMyoRg4+YuRNEjacJk5bVAQ==
dependencies: dependencies:
"@astrojs/webapi" "^1.0.0" "@astrojs/webapi" "^1.0.0"
"@vercel/nft" "^0.18.2" "@vercel/nft" "^0.18.2"