Can someone help me troubleshoot why I am getting ...
# orm-help
g
Can someone help me troubleshoot why I am getting the following error when running a basic query on the client playground? Error:
Cannot return null for non-nullable field DeviceConfig.device.
Datamodel
Copy code
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!
    ...
  }
Query
Copy code
{
  deviceConfig(id:"cjqigyian00ef0d206tg116k5"){
    name
    id
    device{
      model
    }
  }
}
Resolver
Copy code
deviceConfig: async (parent, { id }, context, info) => context.prisma.deviceConfig({ id }, info)
Result
Copy code
{
  "data": null,
  "errors": [
    {
      "message": "Cannot return null for non-nullable field DeviceConfig.device.",
      "locations": [
        {
          "line": 5,
          "column": 5
        }
      ],
      "path": [
        "deviceConfig",
        "device"
      ]
    }
  ]
}
--- When I run the following query on the Prisma API playground it returns Query
Copy code
{
  deviceConfig(where:{id:"cjqigyian00ef0d206tg116k5"}){
    name
    id
    device{
      id
      model
    }
  }
}
Result
Copy code
{
  "data": {
    "deviceConfig": {
      "name": "Standard",
      "id": "cjqigyian00ef0d206tg116k5",
      "device": {
        "id": "cjqigxzs600e60d20sdw38x7p",
        "model": "7530"
      }
    }
  }
}
m
what if you remove async from this line:
deviceConfig: async (parent, { id }, context, info) => context.prisma.deviceConfig({ id }, info)
(edited) there is no await in the function
g
Thanks for the suggestion, but same result.
k
I am not familiar with the syntax of "onDelete" (new feature I haven't caught onto? - I finished writing my datamodel six months ago) It seems suspicious that you have "onDelete: SET_NULL" for a required ("Device!") field. As for the different behavior between resolver results and prisma api results... that is odd.
Found the answer, updated my question and answer. Long story short i was missing some relation resolvers.