PokemonSummary objects optimized for list views, cards, and filtering operations.
adaptPokemonSummary
Converts a single Pokemon entry from a GraphQL response into a summary object.Parameters
A single Pokemon entry from the GraphQL response containing:
id(number): Pokemon IDname(string): Pokemon namepokemontypes(GQLPokemonType[]): Array of type objects with nestedtype.name
Returns
Simplified Pokemon summary object:
Usage Example
Data Structure
Input (GraphQL Response)
The adapter expects data from a GraphQL query with this structure:Output (PokemonSummary)
The adapter flattens and enhances the data:Image URL Generation
The adapter automatically generates sprite image URLs using the Pokemon’s ID:https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/other/home/Fallback ID:
132 (Ditto) if ID is missing or null
Image URL Examples
- Pikachu (ID 25):
https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/other/home/25.png - Charizard (ID 6):
https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/other/home/6.png - Mewtwo (ID 150):
https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/other/home/150.png
Type Transformation
The adapter extracts type names from the nested GraphQL structure:Type Examples
Single Type
Input:
Output:
[{ type: { name: "electric" } }]Output:
["electric"]Dual Type
Input:
Output:
[{ type: { name: "water" } }, { type: { name: "flying" } }]Output:
["water", "flying"]Use Cases
ThePokemonSummary format is ideal for:
List Views
List Views
Display Pokemon in grid or list layouts without loading full details:
Filtering & Search
Filtering & Search
Lightweight objects for fast filtering operations:
Favorites Storage
Favorites Storage
Minimal data structure for localStorage/sessionStorage:
Initial Page Load
Initial Page Load
Fast initial load with summary data before fetching full details:
Performance Benefits
UsingPokemonSummary instead of PokemonDetail provides significant advantages:
- Smaller payload: ~100 bytes vs ~2KB per Pokemon
- Faster parsing: Simple flat structure vs nested objects
- Reduced memory: Ideal for lists of hundreds of Pokemon
- GraphQL optimized: Single query returns all needed data
Related
- Pokemon Service - Uses this adapter in
getPokemonListGQL() - Pokemon Detail Adapter - For full Pokemon data
- usePokeFilters Hook - Filters arrays of
PokemonSummary - Favorite Store - Stores
PokemonSummaryobjects