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

Property hiding #76

Closed
wants to merge 3 commits into from
Closed

Property hiding #76

wants to merge 3 commits into from

Conversation

bring-shrubbery
Copy link

Please see the contributing guidelines for how to create and submit a high-quality PR for this repo.

Description

This PR adds a way of hiding properties of models using a doc string. The API is the same as hiding models, but uses .property instead of .model in the doc string.

Also, here's a list of the things done in this PR:

  • Implements property hiding.
  • Adds example of property hiding to the example Prisma schema file.
  • Adds small documentation section in README for how to use this feature.

References

Implements solution for #75

@bring-shrubbery
Copy link
Author

@omar-dulaimi Tagging you to review this, since you were the one to implement the @@Gen.model(hide: true) feature, hope you don't mind me tagging you :)

@omar-dulaimi
Copy link
Owner

Hey @bring-shrubbery
Thanks for the PR!
I'll take a look

@omar-dulaimi
Copy link
Owner

It seems to be working fine. But I noticed this validation error:

Property 'hiddenField' is missing in type '{ value: string; key: string; }' but required in type 'MapCreateInput'.ts(2322)

It happens in MapCreateInput.schema.ts:

import { z } from 'zod';

import type { Prisma } from '@prisma/client';

const Schema: z.ZodType<Prisma.MapCreateInput> = z
  .object({
    key: z.string(),
    value: z.string(),
  })
  .strict();

export const MapCreateInputObjectSchema = Schema;

To solve it I think we should get rid of the type casting this library currently do z.ZodType<Prisma.MapCreateInput>.

But that would cause issues reported in the past about schemas that reference themselves. I read somewhere that wrapping all generated schemas with z.lazy should solve the issue, but haven't tried that yet.

Also, there seems to be a current problem while ignoring fields, when ignoring the same field hidden, the while create map schemas disappears despite having two remaining fields.

These are all my thoughts so far.

@bring-shrubbery
Copy link
Author

@omar-dulaimi Nice catch! I'll take a look at it this week and will try to implement a fix using your suggestions.

@omar-dulaimi
Copy link
Owner

Hey @bring-shrubbery
Any update on this?

@omar-dulaimi omar-dulaimi marked this pull request as draft May 19, 2023 12:09
@bring-shrubbery bring-shrubbery closed this by deleting the head repository Jul 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants