Skip to content

Commit 8dcb108

Browse files
authored
chore: updating the types of valid read calls someone can make (#988)
1 parent afaf75c commit 8dcb108

File tree

1 file changed

+75
-9
lines changed

1 file changed

+75
-9
lines changed

docs/content/interacting/relationship-queries.mdx

Lines changed: 75 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -198,13 +198,34 @@ The [Read API](/api/service#Relationship%20Tuples/Read) is an API endpoint that
198198

199199
Read can be called if you need to get all the stored relationship tuples that relate:
200200

201-
1. [a particular user to any objects of a specific type with a particular relation](#1-a-particular-user-to-any-objects-of-a-specific-type-with-a-particular-relation)
202-
2. [a particular user to any objects of a specific type with any relation](#2-a-particular-user-to-any-objects-of-a-specific-type-with-any-relation)
203-
3. [a particular object to any user with a particular relation](#3-a-particular-object-to-any-user-with-a-particular-relation)
201+
1. [**user + relation + object**](#1-read-a-tuple-related-to-a-particular-user-relation-and-object)
202+
2. [**user + relation + object type**](#2-read-all-tuples-related-to-a-particular-user-relation-and-object-type)
203+
3. [**user + object** with any relation](#3-read-all-tuples-related-to-a-particular-user-and-object-with-any-relation)
204+
4. [**user + object type** with any relation](#4-read-all-tuples-related-to-a-particular-user-and-object-type-with-any-relation)
205+
5. [**relation + object** for any user](#5-read-all-tuples-related-to-a-particular-relation-and-object-for-any-user)
206+
6. [**object** with any user and relation](#6-read-all-tuples-related-to-a-particular-object-with-any-user-or-relation)
207+
7. [**all** with any user, relation, or object](#7-read-all-tuples-for-any-user-relation-or-object)
204208

205-
#### 1. A particular user to any objects of a specific type with a particular relation
209+
#### 1. Read a tuple related to a particular user, relation, and object
206210

207-
For example, to query all the stored relationship tuples `bob` has a `writer` relationship with, one can ask
211+
For example, to query if `bob` has a `writer` relationship on `document:planning` (essentially finding out if a tuple exists), one can ask
212+
213+
<ReadRequestViewer
214+
user={'user:bob'}
215+
relation={'writer'}
216+
object={'document:planning'}
217+
tuples={[
218+
{
219+
user: 'user:bob',
220+
relation: 'writer',
221+
object: 'document:planning',
222+
},
223+
]}
224+
/>
225+
226+
#### 2. Read all tuples related to a particular user, relation, and object type
227+
228+
For example, to query all the stored relationship tuples `bob` has a `writer` relationship with on type `document:`, one can ask
208229

209230
<ReadRequestViewer
210231
user={'user:bob'}
@@ -219,9 +240,25 @@ For example, to query all the stored relationship tuples `bob` has a `writer` re
219240
]}
220241
/>
221242

222-
#### 2. A particular user to any objects of a specific type with any relation
243+
#### 3. Read all tuples related to a particular user and object with any relation
244+
245+
For example, to query all the stored relationship tuples `bob` has on type `document:planning`, one can ask
246+
247+
<ReadRequestViewer
248+
user={'user:bob'}
249+
object={'document:planning'}
250+
tuples={[
251+
{
252+
user: 'user:bob',
253+
relation: 'writer',
254+
object: 'document:planning',
255+
},
256+
]}
257+
/>
258+
259+
#### 4. Read all tuples related to a particular user and object type with any relation
223260

224-
For example, to query all the stored relationship tuples in which `bob` is related to objects of type `document` as any relation, one can issue the following call:
261+
For example, to query all the stored relationship tuples `bob` has on object type `document:`, one can ask
225262

226263
<ReadRequestViewer
227264
user={'user:bob'}
@@ -235,9 +272,9 @@ For example, to query all the stored relationship tuples in which `bob` is relat
235272
]}
236273
/>
237274

238-
#### 3. A particular object to any user with a particular relation
275+
#### 5. Read all tuples related to a particular relation and object for any user
239276

240-
For example, to query all the stored relationship tuples in which any user is related to `document:planning` as a `writer`, one can issue the following call:
277+
For example, to query all the stored relationship tuples which have the `writer` relation on object `document:planning`, one can ask
241278

242279
<ReadRequestViewer
243280
relation={'writer'}
@@ -251,6 +288,35 @@ For example, to query all the stored relationship tuples in which any user is re
251288
]}
252289
/>
253290

291+
#### 6. Read all tuples related to a particular object with any user or relation
292+
293+
For example, to query all the stored relationship tuples for object `document:planning`, one can ask
294+
295+
<ReadRequestViewer
296+
object={'document:planning'}
297+
tuples={[
298+
{
299+
user: 'user:bob',
300+
relation: 'writer',
301+
object: 'document:planning',
302+
},
303+
]}
304+
/>
305+
306+
#### 7. Read all tuples for any user, relation, or object
307+
308+
For example, to query all stored relationship tuples, one can ask
309+
310+
<ReadRequestViewer
311+
tuples={[
312+
{
313+
user: 'user:bob',
314+
relation: 'writer',
315+
object: 'document:planning',
316+
},
317+
]}
318+
/>
319+
254320
### Caveats and when not to use it
255321

256322
The Read API will only return all the stored relationships that match the query specification.

0 commit comments

Comments
 (0)