Skip to content
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

ability to omit compound unique from typegraphql types #431

Open
shawnjones253 opened this issue Dec 21, 2023 · 5 comments
Open

ability to omit compound unique from typegraphql types #431

shawnjones253 opened this issue Dec 21, 2023 · 5 comments
Labels
community Something initiated by the community enhancement New feature or request priority:low This issue has a low priority and will be done after all the others

Comments

@shawnjones253
Copy link

Is your feature request related to a problem? Please describe.
assume you have this model:

model MyModel {
  id String
  organizationId String

  @@unique([id, organizationId])
}

there doesn't seem to be a way to hide the generated id_organizationId field in typegraphql-generated types (if there is please let me know) :)

Describe the solution you'd like
The clearest way I can think of is to make /// @TypeGraphQL.omit(input: true) work for @@unique

Describe alternatives you've considered
???

@MichalLytek
Copy link
Owner

You need this field in inputs in order to properly find unique records in db via graphql api.

@MichalLytek MichalLytek added the question Further information is requested label Dec 21, 2023
@shawnjones253
Copy link
Author

You need this field in inputs in order to properly find unique records in db via graphql api.

sorry, my example should have marked the id as @unique as well

in my case, i want to expose id as the only unique the caller is allowed to use for input, despite prisma allowing id | id_organizationId

@shawnjones253
Copy link
Author

to make this more clear, i can hide regular @uniques but not @@uniques -- as long as i leave at least one of the regular @uniques available to the caller that should still work with findUnique right?

@shawnjones253
Copy link
Author

shawnjones253 commented Dec 21, 2023

@MichalLytek -- here's a clearer example:

model MyModel {
  id String @unique
  /// @TypeGraphQL.omit(output: true, input: true)
  organizationId String

  @@unique([id, organizationId])
}

this currently generates:

export declare class MyModelWhereUniqueInput {
    id?: string | undefined;
    id_organizationId?: MyModelIdOrganizationIdCompoundUniqueInput | undefined;
}

but what i want to generate instead is:

export declare class MyModelWhereUniqueInput {
    id?: string | undefined;
}

that still has at least one unique field (id) so it would still be usable as input to findUnique

for context, organizationId should be opaque to end users in my application, i'd like to use it in a prisma context without exposing it via the api / typegraphql types

@shawnjones253
Copy link
Author

@MichalLytek see clarification above

@MichalLytek MichalLytek added enhancement New feature or request priority:low This issue has a low priority and will be done after all the others community Something initiated by the community and removed question Further information is requested labels Jan 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
community Something initiated by the community enhancement New feature or request priority:low This issue has a low priority and will be done after all the others
Projects
None yet
Development

No branches or pull requests

2 participants