I am looking to take the result of a TRPC query in Prisma and utilize it as the input for a subsequent query.
Despite following the documentation for React Query dependencies, I am encountering type errors indicating that the output of the first query may be undefined (e.g. product is possibly 'undefined'
):
const { data: product } = api.product.getUnique.useQuery({ id: pid });
const options = api.option.getAll.useQuery(
{
product: product.productSize,
region: product.productRegion,
},
{ enabled: !!product }
);
Shouldn't including "enabled" already address this issue? If not, what is the proper approach to handle this in Typescript?