Mirror: TypeScript LSP plugin that finds GraphQL documents in your code and provides diagnostics, auto-complete and hover-information.
at main 806 B view raw
1import { TypedDocumentNode } from '@graphql-typed-document-node/core'; 2import { createClient, gql } from '@urql/core'; 3 4export const PokemonFields = gql` 5 fragment pokemonFields on Pokemon { 6 id 7 name 8 attacks { 9 fast { 10 damage 11 name 12 } 13 } 14 } 15` as typeof import('./Pokemon.generated').PokemonFieldsFragmentDoc; 16 17export const WeakFields = gql` 18 fragment weaknessFields on Pokemon { 19 weaknesses 20 } 21` as typeof import('./Pokemon.generated').WeaknessFieldsFragmentDoc; 22 23export const Pokemon = (data: any) => { 24 const pokemon = useFragment(PokemonFields, data); 25 return `hi ${pokemon.name}`; 26}; 27 28type X = { hello: string }; 29 30const x: X = { hello: '' }; 31 32export function useFragment<Type>( 33 _fragment: TypedDocumentNode<Type>, 34 data: any 35): Type { 36 return data; 37}