typegraphql-prisma icon indicating copy to clipboard operation
typegraphql-prisma copied to clipboard

Cannot read property 'name' of undefined (version 0.21.2)

Open mdesousa opened this issue 2 years ago • 1 comments

Describe the Bug While executing an updateOne mutation that updates a json column we are getting the error Cannot read property 'name' of undefined

To Reproduce

mutation {
  updateOneMyTable(data:{ myjsonprop: { ... }}, where: { id: "xyz" }) {
    id
  }
}

Expected Behavior The record should update successfully

Logs We are getting the stack trace below. We executed the same query directly in the prisma client and it executed successfully there.

  TypeError: Cannot read property 'name' of undefined
      at isValidEnumValue (/app/node_modules/@prisma/client/runtime/index.js:18037:61)
      at getGraphQLType (/app/node_modules/@prisma/client/runtime/index.js:17986:7)
      at hasCorrectScalarType (/app/node_modules/@prisma/client/runtime/index.js:27652:23)
      at scalarToArg (/app/node_modules/@prisma/client/runtime/index.js:27948:7)
      at tryInferArgs (/app/node_modules/@prisma/client/runtime/index.js:27876:14)
      at valueToArg (/app/node_modules/@prisma/client/runtime/index.js:27738:16)
      at /app/node_modules/@prisma/client/runtime/index.js:27986:18
      at Array.reduce (<anonymous>)
      at objectToArgs (/app/node_modules/@prisma/client/runtime/index.js:27966:28)
      at tryInferArgs (/app/node_modules/@prisma/client/runtime/index.js:27868:40)
      at valueToArg (/app/node_modules/@prisma/client/runtime/index.js:27738:16)
      at /app/node_modules/@prisma/client/runtime/index.js:27986:18
      at Array.reduce (<anonymous>)
      at objectToArgs (/app/node_modules/@prisma/client/runtime/index.js:27966:28)
      at /app/node_modules/@prisma/client/runtime/index.js:27494:48
      at Array.reduce (<anonymous>)
      at selectionToFields (/app/node_modules/@prisma/client/runtime/index.js:27453:36)
      at makeDocument (/app/node_modules/@prisma/client/runtime/index.js:27443:20)
      at PrismaClient._executeRequest (/app/node_modules/@prisma/client/runtime/index.js:29688:23)
      at processTicksAndRejections (internal/process/task_queues.js:95:5)
      at async consumer (/app/node_modules/@prisma/client/runtime/index.js:29618:18)
      at async consumer (/app/node_modules/@prisma/client/runtime/index.js:29618:18) {

Environment (please complete the following information):

  • OS: Ubuntu, MacOS
  • Node v14.19.1
  • typegraphql-prisma version [0.21.2]
  • Prisma version [4.1.1]
  • TypeScript version [4.7.4]

mdesousa avatar Jul 29 '22 19:07 mdesousa

Please edit the generated repository method source code and add console.log for debugging the payload passed into prisma client.

MichalLytek avatar Jul 29 '22 20:07 MichalLytek

Closing for a housekeeping purposes 🔒

MichalLytek avatar Mar 22 '23 14:03 MichalLytek