Cauen / prisma-generator-pothos-codegen

The fastest way to create a fully customizable CRUD Graphql API from Prisma Schema.
https://www.npmjs.com/package/prisma-generator-pothos-codegen
100 stars 19 forks source link

TypeError: Cannot read properties of undefined (reading 'scalarType') #64

Closed taylorbindon closed 10 months ago

taylorbindon commented 10 months ago

Hi all! Appreciate the great work on the package so far.

I'm working with a team that are migrating from nexus to pothos. We've used auto generated crud in the past and would like to going forward for this project.

We've run into a strange issue. It looks like the inputs file is not getting the builder correctly. The path is correct but we keep getting this error: TypeError: Cannot read properties of undefined (reading 'scalarType'). This happens specifically at the first scalar in the input file (DateTime). See screenshot attached at line 37 builder.scalarType.

image

I'm running: Node: 20.10 @pothos/core: ^3.41.0 @pothos/plugin-prisma: ^3.63.1 @prisma/client: ^5.7.1 prisma: ^5.7.1

It's strange because the generated files are picking up the inputs file and the builder, but specifically the inputs file is not picking up the builder. Worth noting the path is correct and is exporting correctly as all the generated files get the builder fine as I said.

Any help would be great!

Cauen commented 10 months ago

Hello @taylorbindon Can you please setup a small example with that error? The example in repo does work for you?

taylorbindon commented 10 months ago

I've tried to follow the example as best as I can, everything seems to be fine except this.

Code sandbox below is a very minimal reproduction but this time it's enumType instead of Scalar. The Prisma scalar definitions aren't coming through from the package on code sandbox for some reason.

Code sandbox example

Cauen commented 10 months ago

Have you setup builderLocation? image

taylorbindon commented 10 months ago

Yeah tried that as well, locally I still get scalarType error, code sand box still gets enumType error. Have you run into this before?

Cauen commented 10 months ago

Its a problem with circular dependency Please break builder into an isolated file

See the fix

https://github.com/Cauen/pgpc-issue-64/commit/c1607faacbdc2c8c6cdac40263e2e7c7073b325b

Does it resolve your issue?

taylorbindon commented 10 months ago

Legend, makes sense! Sure enough it's fixed now.

Appreciate the help!