When I try to return fields from a one-to-many relation in Prisma client playground it returns the following error:
Cannot return null for non-nullable field DeviceConfig.device.
What in my resolver or client could be causing this?
When running the following query on the backend Prisma API playground it does return the correct data so that tells me my mutations and relationship is good.
Datamodel
type Device {
...
model: String! @unique
...
configs: [DeviceConfig] @relation(name: "DeviceConfigs", onDelete: CASCADE)
}
type DeviceConfig {
id: ID! @unique
device: Device! @relation(name: "DeviceConfigs", onDelete: SET_NULL)
name: String!
...
}
Resolver
deviceConfig: async (parent, { id }, context, info) => context.prisma.deviceConfig({ id }, info)
Query
{
deviceConfig(id:"cjqigyian00ef0d206tg116k5"){
name
id
device{
model
}
}
}
Result
{
"data": null,
"errors": [
{
"message": "Cannot return null for non-nullable field DeviceConfig.device.",
"locations": [
{
"line": 5,
"column": 5
}
],
"path": [
"deviceConfig",
"device"
]
}
]
}
I expect the query to return the model of the device like the backend Prisma API server does Query
{
deviceConfig(where:{id:"cjqigyian00ef0d206tg116k5"}){
name
id
device{
id
model
}
}
}
Result
{
"data": {
"deviceConfig": {
"name": "Standard",
"id": "cjqigyian00ef0d206tg116k5",
"device": {
"id": "cjqigxzs600e60d20sdw38x7p",
"model": "7530"
}
}
}
}