A single condition that must be met for a conditional permission to be required. Each condition checks whether a field equals one of the expected values. When multiple conditions are specified in a conditional_permission, ALL must be true (AND logic). ## Condition Types Use either `value` OR `exists`, not both: - **value**: Check if a field matches specific values (e.g., `value: ["true"]`) - **exists**: Check if a value/entity exists or not (e.g., `exists: true`) ## Examples ```elixir # Check field value %{field: "is_controlled", value: ["true"]} # Check entity exists %{entity_module: "Vetspire.Billing.Product", entity_id_path: "input.product_id", exists: true} # Check entity does NOT exist %{entity_module: "Vetspire.Billing.Product", entity_id_path: "input.product_id", exists: false} # Check if a field on the entity has a value %{field: "manufacturer_id", entity_module: "Vetspire.Billing.Product", entity_id_path: "id", exists: true} # Check if input field was provided (no entity lookup) %{field: "input.prescriber_id", exists: true} ```
query { # Use this type in your queries someQuery { entityIdPath entityModule exists field value }}entityIdPathStringDot-notation path to the entity ID in the GraphQL arguments (e.g., 'input.product_id', 'medication_id'). Used to fetch the related entity for conditional permission checking. Required when entity_module is specified.
entityModuleStringThe Elixir module name for the entity to check (e.g., 'Vetspire.Clinical.Medication'). When specified with entity_id_path: - The system extracts the entity ID from GraphQL arguments using the path - Fetches the entity from the database using this module - Checks the field value on the fetched entity When not specified: - The field value is checked directly on the input arguments - Useful for permissions based on values provided in the GraphQL request
existsBooleanCheck if the value/entity exists (true) or does not exist (false). Cannot be used with `value`.
fieldStringThe field name to check on the resource (e.g., 'is_controlled', 'status'). Required when using `value`, optional when using `exists` with an entity.
value[String]The expected field values that trigger this permission requirement (e.g., ['true'], ['active', 'pending']). Cannot be used with `exists`.