Skip to content

TRPC results in runtime error when creating a model inherited from a delegate model #1608

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
ymc9 opened this issue Jul 22, 2024 · 0 comments
Milestone

Comments

@ymc9
Copy link
Member

ymc9 commented Jul 22, 2024

model Content  {
  id          Int      @id @default(autoincrement())
  user       User @relation(fields: [userId], references: [id])
  userId    String @default(auth().id)

  contentType String

  @@delegate(contentType)

  @@allow('all', true)
}


model Post extends  Content {
  title String
}
const create = trpc.post.create.useMutation();

const onClick = async () => {
        if (user?.id) {
            await create.mutateAsync({
                data: {
                    title: 'title post',
                },
            });
        }
    };
TRPCClientError: [
  {
    "code": "invalid_union",
    "unionErrors": [
      {
        "issues": [
          {
            "code": "invalid_type",
            "expected": "string",
            "received": "undefined",
            "path": [
              "data",
              "contentType"
            ],
            "message": "Required"
          }
        ],
        "name": "ZodError"
      },
      {
        "issues": [
          {
            "code": "invalid_type",
            "expected": "string",
            "received": "undefined",
            "path": [
              "data",
              "contentType"
            ],
            "message": "Required"
          }
        ],
        "name": "ZodError"
      }
    ],
    "path": [
      "data"
    ],
    "message": "Invalid input"
  }
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant