Mirror: TypeScript LSP plugin that finds GraphQL documents in your code and provides diagnostics, auto-complete and hover-information.
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 pokemon = useFragment(PokemonFields, data); 19 return `hi ${pokemon.name}`; 20}; 21 22type X = { hello: string }; 23 24const x: X = { hello: '' }; 25 26export function useFragment<Type>( 27 _fragment: TypedDocumentNode<Type>, 28 data: any 29): Type { 30 return data; 31}