feat: add limit parameter to search API

This commit is contained in:
2024-06-05 21:45:32 -04:00
parent ad61f3d18a
commit 4812e56296
4 changed files with 12 additions and 7 deletions

View File

@@ -2,8 +2,8 @@ import { graphql } from "gql.tada";
import { GraphQLClient } from "graphql-request";
const SearchQuery = graphql(`
query Search($query: String!, $page: Int!) {
Page(page: $page) {
query Search($query: String!, $page: Int!, $limit: Int!) {
Page(page: $page, perPage: $limit) {
media(search: $query, type: ANIME, sort: [POPULARITY_DESC, SCORE_DESC]) {
id
title {
@@ -26,11 +26,12 @@ const SearchQuery = graphql(`
export async function fetchSearchResultsFromAnilist(
query: string,
page: number,
limit: number,
) {
const client = new GraphQLClient("https://graphql.anilist.co/");
return client
.request(SearchQuery, { page, query })
.request(SearchQuery, { page, query, limit })
.then((data) => data?.Page)
.then((page) => {
if (!page || page.media?.length === 0) {