lolopinto / ent

MIT License
51 stars 6 forks source link

GraphQL Error: "message": "options.ctr is not a constructor" when using fieldEdge? #1782

Open ashleyxue529 opened 6 months ago

ashleyxue529 commented 6 months ago

Setup is like this:

UserSchema:
...
 fields: {
    foodID: UUIDType({
      fieldEdge: { schema: "Food", inverseEdge: "users" },
    }),
...

FoodSchema:
...
edges: [
    {
      name: "users",
      schemaName: "User",
    },

Codegen is successful, but I think some files/naming is missing/incorrect? When running the query in GraphiQL, it produces the error "message": "options.ctr is not a constructor". I saw that in user_to_foods_connection_type.ts, UserToFoodsEdge is missing:

import { UserToFoodsEdge } from "src/ent/";

Am I missing something in my setup?

lolopinto commented 6 months ago

I'm not sure. this might be a weird pluralization thing

are you using v0.1. or v0.2.?

UserToFoodsEdge should be defined in src/ent/user/query/user_to_foods_query.ts based on your schema

are you using docker or running locally?

if you're using docker, can you run with --write-all

docker-compose -f docker-compose.dev.yml run --rm app tsent codegen --write-all

or locally:

tsent codegen --write-all