MichalLytek / MichalLytek/typegraphql-prisma

Disable nested create/upsert globally for a model while preserving connect

Open
#485 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

bug community
Dominant language
TypeScript
Stars
918
Forks
130
PR merge metrics
No merged PRs in 30d

Description

Context:
We need to globally disable nested create for entities from any related entities (while keeping only connect), so users can’t bypass business rules by creating entities nested. Example: There is an Items entity with many Blocks. Items can only be created by an admin, while Blocks can be created by any user. We need to ensure a regular user cannot create Items nested when creating Blocks.

Tried:
Using @TypeGraphQL.omit(input: ["create", "update"]) on a relation field (e.g., blocks.item) — this removes the entire relation from inputs, including connect, which doesn’t work for us.
Programmatic applyInputTypesEnhanceMap to hide create/connectOrCreate/upsert/createMany in all nested input containers for Items, keeping connect. This works, but it iterates over all input types in the schema — it’s heavy, and whenever the schema grows, we need to run this again and restrict new inputs.

Question:
Is there a built-in way in typegraphql-prisma, at generation time, to disable nested create/connectOrCreate/upsert for a specific model/relation (e.g., for Items) while preserving connect? Essentially, a “globally disable nested create for model X” switch.
I’d appreciate any recommendations or links to up-to-date examples/documentation for this use case.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the mentioned applyInputTypesEnhanceMap approach and the generator's input-type generation configuration. Determine whether a model- or relation-level generation option can suppress nested create, connectOrCreate, upsert, and createMany while retaining connect; done means the behavior is available at generation time without scanning every schema input type.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
authorization, backend-api-design
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.