mirror of
https://github.com/MetaFam/TheGame.git
synced 2026-02-12 15:05:02 -05:00
21 lines
440 B
TypeScript
21 lines
440 B
TypeScript
import { Pokemon } from '../types/pokemon';
|
|
import { client } from './client'
|
|
|
|
const pokemonQuery = `
|
|
query firstTwentyPokemons($name: String!) {
|
|
pokemon(name: $name) {
|
|
name
|
|
image
|
|
}
|
|
}
|
|
`
|
|
|
|
export const getPokemon = async (name: string | undefined): Promise<Pokemon | null> => {
|
|
if (!name) return null;
|
|
const {
|
|
data: { pokemon },
|
|
} = await client.query(pokemonQuery, { name }).toPromise()
|
|
|
|
return pokemon
|
|
}
|