export const getDecks: GetDeck<any, Deck[]> = async (args, context) => {
return context.entities.Deck.findMany({
where: {
userId: context.user.id
},
include: {
cards: true
},
});
}
// in frontend:
const { data: decks, isLoading, error } = useQuery(getDecks);
const firstCard = decks[0].cards[0];
// ^ typescript error
// type Deck does not have a `cards` member
export const getDecks: GetDeck<any, Deck[]> = async (args, context) => {
return context.entities.Deck.findMany({
where: {
userId: context.user.id
},
include: {
cards: true
},
});
}
// in frontend:
const { data: decks, isLoading, error } = useQuery(getDecks);
const firstCard = decks[0].cards[0];
// ^ typescript error
// type Deck does not have a `cards` member