Skip to content

ReadRelationships: what is the difference between relationship_filter.optional_relation and nested subject_filter.optional_relation? #1861

Answered by vroldanbet
theronic asked this question in Q&A
Discussion options

You must be logged in to vote

@theronic in SpiceDB the subject optional relation allows you to reference, instead of a subject entity, a relation in a subject entity. If you think of a graph, what this allows you to is to reference an edge instead of a node. Example:

definition user {}
 
definition team {
  relation member: user
}
 
definition resource {
  relation reader: user | team#member
  permission view = reader
}
```

In this example, the resource `reader` relation can be assigned to a user or to the members of a team. The `member` part of `team#member` is denoted with `optional_subject_filter.optional_relation` 

Replies: 3 comments 5 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
5 replies
@vroldanbet
Comment options

Answer selected by vroldanbet
@theronic
Comment options

@vroldanbet
Comment options

@theronic
Comment options

@vroldanbet
Comment options

Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants