import { gql, useQuery } from '@apollo/client'; interface PostQuery { posts: { id: string title: string author?: { id: string firstName: string lastName: string } }[] } const postsQueryDocument = gql` query Posts { posts { id title author { id firstName lastName } } } ` const Posts = () => { const { data } = useQuery<PostQuery>(postsQueryDocument); // ... }