Hi, I was wondering: what if I have a field in the...
# orm-help
e
Hi, I was wondering: what if I have a field in the prisma schema that I don't want to expose. Can I white or black list those fields, like suggested here https://www.prisma.io/forum/t/create-private-field-using-directive/3669 ? I mean, I still want to store a field but I just don't want it exposed to the client. Do I then need to define that whole type but without the "private" field, like below? `database/datamodel.graphql`:
Copy code
type Foo {
  foo: String
  privateBar: String
}
`src/schema.graphql`:
Copy code
type Foo {
  foo: String
}
d
I think you could do that, since
src\schema.graphql
is a from the GraphQL server connecting to your Prisma schema
m
Yes, you can definitely do so!
k
Here is an example using a project I'm working on. Very simple, I want to be sure to never expose my User's
password
field and only sometimes expose my User's
email
field. The no-password, no-email is default
User
type, which the other Schemas will return (say for example, if it's a blog, you can look up a
User
in the Author field of a
Post
. https://github.com/TiE23/metric-teacher/blob/ISSUE-020/server/src/schema.graphql#L96 But for cases where a User wants to look at their own data (like on their settings page) and expose their email (but still not their password) my type
PrivateUser
will be returned in my
me
query. https://github.com/TiE23/metric-teacher/blob/ISSUE-020/server/src/schema.graphql#L109
e
cool, thanks!!