WaspW
Wasp11mo ago
Noah

Supporting decimals in prisma schema

My schema has fields like so:

model PaymentRule {
  id          String    @id @default(uuid())
  venueId     String    
  venue       Venue     @relation(fields: [venueId], 
  pricePerHour  Decimal
}


Then when I write an operation to fetch Payment rules, I get the following error:

export const getVenueById: GetVenueById<
  GetVenueByIdPayload,
  (Venue & { spaces: Space[]; availabilityRules: AvailabilityRule[]; paymentRules: PaymentRule[] }) | null
> = async (args, context) => {
  return context.entities.Venue.findFirst({
    where: { id: args.venueId },
    include: {
      spaces: true,
      availabilityRules: true,
      paymentRules: true,
    },
  });
};


 Property 'paymentRules' is incompatible with index signature.
        Type '{ id: string; venueId: string; spaceIds: string[]; priority: number; ruleType: RuleType; pricePerHour: Decimal | null; multiplier: Decimal | null; discountRate: Decimal | null; ... 8 more ...; updatedAt: Date; }[]' is not assignable to type 'SuperJSONValue'.
...
                Property 'pricePerHour' is incompatible with index signature.
                  Type 'Decimal | null' is not assignable to type 'SuperJSONValue'.
                    Type 'Decimal' is not assignable to type 'SuperJSONValue'.
                      Type 'Decimal' is not assignable to type 'SuperJSONObject'.
                        Index signature for type 'string' is missing in type 'Decimal'.ts(2344)


How to resolve??
Was this page helpful?