I just started trying out the fluent API and I've ...
# orm-help
c
I just started trying out the fluent API and I've noticed that if the last call doesn't find any records, the query returns null instead of an empty array like you would get from
findMany()
which is a bummer because if I just return that to Apollo it throws an error like
"message": "Cannot return null for non-nullable field Query.employeeNotes."
. Is this a known issue that will get fixed? In the meantime as a workaround I have to await the result of the query and use the nullish coalescing operator to return an empty array if there are no results:
Copy code
async getEmployeeNotes(employeeId: string): Promise<EmployeeNote[]> {
    return (
      (await prisma.employee
        .findUnique({
          where: {
            id: employeeId,
          },
        })
        .employeeNotes()) ?? []
    )
  },