-
Notifications
You must be signed in to change notification settings - Fork 1k
Open
Labels
bug/confirmedWe have confirmed this is a bugWe have confirmed this is a bugtopic/graphqltopic/prismatopic/typescript
Description
What's not working?
This is the generated code:
export const createUnit: MutationResolvers['createUnit'] = ({ input }) => {
return db.unit.create({
data: input,
})
}
data
gets red squiggles.
To dig a bit deeper in what's wrong you can do this to get better type info
type CreateUnitInput = Parameters<MutationResolvers['createUnit']>[0]['input']
export const createUnitCustom: MutationResolvers['createUnit'] = ({
input,
}: {
input: CreateUnitInput
}) => {
What Prisma is expecting is this:
/**
* Unit create
*/
export type UnitCreateArgs<ExtArgs extends $Extensions.InternalArgs = $Extensions.DefaultArgs> = {
/**
* Select specific fields to fetch from the Unit
*/
select?: UnitSelect<ExtArgs> | null
/**
* Choose, which related nodes to fetch as well
*/
include?: UnitInclude<ExtArgs> | null
/**
* The data needed to create a Unit.
*/
data: XOR<UnitCreateInput, UnitUncheckedCreateInput>
}
Especially data
is interesting. It wants either UnitCreateInput
xor UnitUncheckedCreateInput
And that's not what our generated types are.
How do we reproduce the bug?
I haven't created a minimal reproduction yet, but you at least need two prisma models where one model has a relation to the other. I don't know if there are more specific requirements than that to trigger the bug.
This might be enough of my schema to trigger the issue
model Unit {
id String @id
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
name String
restaurant Restaurant @relation(fields: [restaurantId], references: [id])
restaurantId String
}
model Restaurant {
id String @id @default(cuid())
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
name String
units Unit[]
}
What's your environment? (If it applies)
yarn rw info
System:
OS: macOS 15.2
Shell: 5.9 - /bin/zsh
Binaries:
Node: 22.14.0 - /private/var/folders/7j/9p56mwmj6jsfdr2h5_884j9w0000gn/T/xfs-75cb72c7/node
Yarn: 4.4.0 - /private/var/folders/7j/9p56mwmj6jsfdr2h5_884j9w0000gn/T/xfs-75cb72c7/yarn
Databases:
SQLite: 3.43.2 - /usr/bin/sqlite3
Browsers:
Safari: 18.2
npmPackages:
@redwoodjs/auth-dbauth-setup: 8.2.0 => 8.2.0
@redwoodjs/core: 8.2.0 => 8.2.0
@redwoodjs/project-config: 8.2.0 => 8.2.0
redwood.toml:
[web]
title = "Victory"
port = 8910
apiUrl = "/.redwood/functions"
includeEnvironmentVariables = [
# Add any ENV vars that should be available to the web side to this array
# See https://redwoodjs.com/docs/environment-variables#web
]
[api]
port = 8911
[browser]
open = true
[notifications]
versionUpdates = ["latest"]
[generate]
tests = false
stories = false
Are you interested in working on this?
- I'm interested in working on this
tejasurya-p
Metadata
Metadata
Assignees
Labels
bug/confirmedWe have confirmed this is a bugWe have confirmed this is a bugtopic/graphqltopic/prismatopic/typescript