Below is the code I am working with:
import { useQuery } from "@vue/apollo-composable";
const ACCOUNTS_QUERY = gql`
{
accounts {
id
name
number
}
}
`;
interface Accounts {
accounts: [
{
id: number;
name: string;
number: string;
}
];
}
export default defineComponent({
name: "AccountsView",
setup() {
const { result, loading, error } = useQuery<Accounts>(ACCOUNTS_QUERY);
return {
accounts: result.accounts,
}
I encountered the TS2339 error: Property 'accounts' does not exist on type 'Ref<Accounts | undefined>' in the return.
If I change the return statement to:
return {
result,
}
By doing this, I can access result.accounts
in the template and iterate over it using v-for
. But why am I unable to directly return result.accounts
?