Files
TheGame/packages/web/graphql/getPokemon.ts
Pacien Boisson 08a4b90d95 Update models (#33)
* Remove unused models

* add new props into Player model

* Added props to Guild

* Setting guild type as a foreign-key reference

* Use foreign table for skills

* Seed data

* prettier
2020-07-27 10:08:48 +02:00

23 lines
450 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;
};