Overview
The AnimeThemes Web application uses GraphQL to fetch data from the AnimeThemes API. This page documents the available queries and how to use them in your pages.Root Queries
The GraphQL schema provides several root queries for fetching different types of resources:Anime Queries
anime
Fetch a single anime by ID or slug.
id(Int): The anime IDslug(String): The anime slug
animeAll
Fetch a list of anime with optional filters.
limit(Int): Maximum number of resultsyear(Int): Filter by yearseason(String): Filter by season (Winter, Spring, Summer, Fall)
Theme Queries
theme
Fetch a single theme by ID.
themeAll
Fetch a list of themes with sorting and filtering.
limit(Int): Maximum number of resultsorderBy(String): Field to sort byorderDesc(Boolean): Sort in descending orderhas(String): Filter by relationship existence
Artist Queries
artist
Fetch a single artist by ID or slug.
artistAll
Fetch a list of artists.
Other Resource Queries
series / seriesAll
Query anime series.
studio / studioAll
Query animation studios.
year / yearAll
Query by year and season.
Special Queries
featuredTheme
Get the currently featured theme.
playlist / playlistAll
Query user playlists.
me
Query the authenticated user’s data.
Using Includes
The GraphQL API uses a concept of “includes” to fetch related data. When you query a field that requires related data, the resolver automatically constructs the appropriate API request with includes. For example, to fetch an anime with its themes:include[anime]=animethemes.song.animethemeentries.videos to the API request.
Real-World Examples
Homepage Query
From/src/pages/index.tsx:
Anime Detail Query
From/src/pages/anime/[animeSlug]/index.tsx:
Artist Detail Query
From/src/pages/artist/[artistSlug]/index.tsx:
Using GraphQL in Pages
In Next.js pages, queries are used with thefetchData function:
Query Fragments
Fragments help reuse common query patterns:Next Steps
- GraphQL Types - Learn about the available types and their fields
- GraphQL Resolvers - Understand how resolvers fetch data from the API