The test on tutorial Creating a Comment Form | RedwoodJS Docs, say
api/src/services/comments/comments.test.jsx
import { comments, createComment } from ‘./comments’
import { db } from ‘src/lib/db’
describe(‘comments’, () => {
scenario(‘returns all comments’, async (scenario) => {
const result = await comments({ postId: scenario.comment.jane.postId })
const post = await db.post.findUnique({
where: { id: scenario.comment.jane.postId },
include: { comments: true },
})
expect(result.length).toEqual(post.comments.length)
})
But I got this error when running the test or run the db.post.findUnique on yarn rw console
db.post.findUnique({ where: { id: 1 }, include: { comments: true }, })
{“level”:50,“time”:1693212588537,“pid”:37274,“hostname”:“mohammad-81yh”,“prisma”:{“clientVersion”:“5.0.0”},“timestamp”:“2023-08-28T08:49:48.536Z”,“message”:“\nInvalidprisma.post.findUnique()
invocation:\n\n\nCannot select both ‘$scalars: true’ and a specific scalar field ‘comments’.”,“target”:“post.findUnique”,“msg”:“\nInvalidprisma.post.findUnique()
invocation:\n\n\nCannot select both ‘$scalars: true’ and a specific scalar field ‘comments’.”}
Uncaught PrismaClientUnknownRequestError:
Invalidprisma.post.findUnique()
invocation:
Cannot select both ‘$scalars: true’ and a specific scalar field ‘comments’.
at zr.request (/mnt/storage2/Projects/skripsi/redwood-tutorial/node_modules/@prisma/client/runtime/library.js:122:7307)
at zr.handleAndLogRequestError (/mnt/storage2/Projects/skripsi/redwood-tutorial/node_modules/@prisma/client/runtime/library.js:122:7697)
at zr.handleRequestError (/mnt/storage2/Projects/skripsi/redwood-tutorial/node_modules/@prisma/client/runtime/library.js:122:8480) {
clientVersion: ‘5.0.0’