prisma-nestjs-graphql icon indicating copy to clipboard operation
prisma-nestjs-graphql copied to clipboard

How to hide an entire model? (hide enum)

Open IgnisDa opened this issue 3 years ago • 7 comments
trafficstars

I have a model that I don't want to expose to my graphql schema at all. The below does not work. Is there an existing solution?

/// @HideField({input: true, output: true})
model JobLog {
 id   Int
 data JSON
}

IgnisDa avatar Jan 18 '22 15:01 IgnisDa

Okay just realized it works with

/// @ObjectType({abstract: true})
model JobLog {
 id   Int
 data JSON
}

But it does not work for enums.

IgnisDa avatar Jan 18 '22 15:01 IgnisDa

I'm not sure that understand the reason to hide enum. Making model abstract make sense if you want extends and override some fields, but how you will extend enum and how it will work with enum in prisma?

unlight avatar Jan 19 '22 08:01 unlight

I dont want to extend my enum, I just want to remove it from my schema entirely. Right now, its being added to my graphql schema which I don't want.

IgnisDa avatar Jan 19 '22 09:01 IgnisDa

Are you removed all fields from all models with this enum type?

unlight avatar Jan 20 '22 07:01 unlight

Yes i did

IgnisDa avatar Jan 20 '22 07:01 IgnisDa

I added @HideField({ input: true, model: true, output: true }) to my example https://github.com/unlight/prisma-nestjs-graphql/blob/4f2cb69b349fda560b5a83780778ad2f8d7594c6/prisma/schema.prisma#L59

And enum Role is disappeared from schema, despite @generated/prisma/role.enum.ts in requiring during application start and registerEnumType(Role, { name: 'Role', description: undefined }); is definitely called.

unlight avatar May 02 '22 19:05 unlight

@IgnisDa Could you check this again in your project

unlight avatar May 02 '22 20:05 unlight