Exclude certain models from being generated
mikerudge opened this issue · 4 comments
Hey
Is there a good way to tell prisma-appsync to ignore certain models and ideally certain fields from being generated?
We have models that we don't want part of the API but need to have as part of our Prisma schema.
As always, thanks for all your work on this.
Mike
Oh, I found it!
In case anyone else comes across this issue, here is the syntax I was missing.
/// @gql(queries: null, subscriptions: null, mutations: null)
model VerificationToken {
id String @id @default(auto()) @map("_id") @db.ObjectId
}
@mikerudge I'm currently working on the documentation on how to tweak the GraphQL Schema output using the @gql
directive. For now, you can find some examples here: #88 (comment)
Also, another way to disable the entire model (queries
+ subscriptions
+ mutations
all at once) is:
/// @gql(model: null)
model VerificationToken {
id String @id @default(auto()) @map("_id") @db.ObjectId
}
That's great, worked perfectly thank you.
Using that syntax is there a way to set a field to read-only?
Basically exclude the field from any mutation but leave it in the query.
If this excludes it all.
fields: { text: null }
Something like
fields: { text: {mutation: null} }
@mikerudge Right now there is no way to set a read-only field with the @gql
directive. But happy to consider this as a new Feature request.
In the meantime, I would suggest either using a Before Hook, or a Prisma middleware with custom logic to make the fields read-only.