I’m going to start with a simplified graphql schema:
type Owner {
name: String!
}
type Manager {
name: String!
}
type Property {
name: String!
address: String
purchasePrice: Long
owner: Owner! @relation
}
I have two user-types Owners and Managers. Those users have separate roles: an owner-role, and a manager-role. I want to allow managers to access owner-properties, but I want to hide the purchasePrice
from them.
After trying several options, it seems my only option is to update the data model to something like this:
type Owner {
name: String!
}
type Manager {
name: String!
}
type Property {
name: String!
address: String
owner: Owner! @relation
ownerOnlyDetails: OwnerOnlyPropertyDetails @relation
}
type OwnerOnlyPropertyDetails {
purchasePrice: Long
property: Property! @relation
}
By placing the data I want to hide in a different collection, I can give Managers access to the Property
type, while denying access to the OwnerOnlyPropertyDetails
Unfortunately, having to update the data model in this way introduces a lot of work in an application, so I was trying to avoid it.