Prisma-AppSync provides ways to tweak and customise the GraphQL Schema output.
Tweaking the GraphQL schema for a given model require to write directives via AST comments (triple-slash ///
).
/// @gql(mutations: null, subscriptions: null)
/// @gql(fields: { password: null })
/// @gql(scalars: { email: "AWSEmail" })
model User {
id Int @id @default(autoincrement())
email String
password String
}
// Disable all queries, mutations and subscriptions
@gql(model: null)
// Disable all queries (get, list, count, ...)
@gql(queries: null)
// Disable granular queries
@gql(queries: { list: null, count: null })
// Disable all mutations (create, update, upsert, delete, ...)
@gql(mutations: null)
// Disable granular mutations
@gql(mutations: { update: null, delete: null })
Cascading Rules:
- Disabling
update
will also disableupsert
- Disabling
create
will also disableupsert
- Disabling
mutations
will also disablesubscriptions
// Disable all subscriptions (onCreated, onUpdated, ...)
@gql(subscriptions: null)
// Disable granular subscriptions
@gql(mutations: { onCreated: null, onUpdated: null })
// If applied to a model with a `password` field:
// hide `password` field from the generated Type
@gql(fields: { password: null })
Note: To maintain Prisma Client integrity, hidden fields remain writable in mutation operations.
// If applied to a model with a `website` (string) field:
// use scalar `AWSURL` instead of default `String`
@gql(scalars: { website: "AWSURL" })