Mirror: TypeScript LSP plugin that finds GraphQL documents in your code and provides diagnostics, auto-complete and hover-information.
at main 507 B view raw
1import { TypedDocumentNode } from '@graphql-typed-document-node/core'; 2import { graphql } from './gql'; 3 4export const PokemonFields = graphql(` 5 fragment pokemonFields on Pokemon { 6 id 7 name 8 attacks { 9 fast { 10 damage 11 name 12 } 13 } 14 } 15`) 16 17export const Pokemon = (data: any) => { 18 const { name } = useFragment(PokemonFields, data); 19 return `hi ${name}`; 20}; 21 22export function useFragment<Type>( 23 _fragment: TypedDocumentNode<Type>, 24 data: any 25): Type { 26 return data; 27}