refactor!: migrate from REST API to GraphQL
- Replace OpenAPI/REST endpoints with a single route. - Remove and Swagger UI configuration. - Disable OpenAPI schema extensions in Zod types. - Refactor to be request-agnostic. - Update episode URL fetching to return standardized success/failure objects. - Update project dependencies.
This commit is contained in:
31
src/graphql/resolvers/queries/popularBrowse.ts
Normal file
31
src/graphql/resolvers/queries/popularBrowse.ts
Normal file
@@ -0,0 +1,31 @@
|
||||
import { GraphQLError } from "graphql";
|
||||
|
||||
import { fetchPopularTitlesFromAnilist } from "~/controllers/popular/browse/anilist";
|
||||
|
||||
import type { GraphQLContext } from "../../context";
|
||||
|
||||
interface PopularBrowseArgs {
|
||||
limit?: number;
|
||||
}
|
||||
|
||||
export async function popularBrowse(
|
||||
_parent: unknown,
|
||||
args: PopularBrowseArgs,
|
||||
_context: GraphQLContext,
|
||||
) {
|
||||
const { limit = 10 } = args;
|
||||
|
||||
const response = await fetchPopularTitlesFromAnilist(limit);
|
||||
|
||||
if (!response) {
|
||||
throw new GraphQLError("Failed to fetch popular titles", {
|
||||
extensions: { code: "INTERNAL_SERVER_ERROR" },
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
trending: response.trending || [],
|
||||
popular: response.popular || [],
|
||||
upcoming: response.upcoming || [],
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user