WaspW
Wasp2y ago
wardbox

Typescript not validating included relation

This is likely due to my inexperience with typescript, but I've been trying to access a related property that I've included on a query, but for some reason typescript isn't validating that it's a valid property. I think it only has scalar properties available.

  const { data: team, status } = useQuery(getTeamById, { id: props.match.params.id });
  console.log(team.logo);

gives this error:
Property 'logo' does not exist on type 'GetResult<{ id: string; name: string; createdAt: Date; }, unknown> & {}'.ts(2339)


export const getTeamById: GetTeamById<{ id: string }, Team> = async ({ id }, context) => {
  if (!context.user) {
    throw new HttpError(401);
  }

  try {
    const team = await context.entities.Team.findFirstOrThrow({
      where: {
        id: id
      },
      include: {
        logo: true,
      }
    });
    return team;
  } catch (error: any) {
    throw new HttpError(404, error.message);
  }
}


I'd expect prisma and/or wasp handles the types when i run wasp db migrate-dev , is that not correct?
Was this page helpful?