1import { FragmentOf, graphql, readFragment } from './graphql';
2
3export const Fields = { Pokemon: graphql(`
4 fragment Pok on Pokemon {
5 resistant
6 }`)
7}
8
9export const PokemonFields = graphql(/* GraphQL */`
10 fragment pokemonFields on Pokemon {
11 name
12 weight {
13 minimum
14 }
15 }
16`);
17
18interface Props {
19 data: (FragmentOf<typeof PokemonFields> & FragmentOf<typeof Fields.Pokemon>) | null;
20}
21
22export const Pokemon = ({ data }: Props) => {
23 const pokemon = readFragment(PokemonFields, data);
24 const resistant = readFragment(Fields.Pokemon, data);
25 if (!pokemon || !resistant) {
26 return null;
27 }
28
29 return (
30 <li>
31 {pokemon.name}
32 {resistant.resistant}
33 </li>
34 );
35};