Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update UC of partial collection #165

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 33 additions & 28 deletions drafts/use-cases/3.2.pagination.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ So I can start reviewing them with option of loading more on demand.

```javascript
const client = new HydraClient();
let data = client.get("/api/events");
for (const member of data.members) {
let collection = client.get("/api/events");
for (const member of collection.members) {
// do something with the _member_, i.e. display it
}
// load some more on demand
data = client.get(data.next);
for (const member of data.members) {
collection = client.get(data.view[0].next);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alien-mcl Maybe this snippet could already use the new API as proposed in HydraCG/Heracles.ts#34

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's a good idea. I'll try to update that PR with API "release candidate" :)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I am correct we have also replaced get method with getResource. If no one is working on this then I would like to create a PR adapting use cases to new client API.

for (const member of collection.members) {
// do something with more _member_, i.e. display it
}
```
Expand All @@ -49,24 +49,27 @@ HTTP 200 OK
{
"@context": "/api/context.jsonld",
"@id": "/api/events",
"@type": "PartialCollection",
"@type": "Collection",
"manages": {
"property": "rdf:type",
"object": "schema:Event"
},
"next": "/api/events?page=2",
"first": "/api/events",
"last": "/api/events?page=2",
"totalItems": 1,
"member": [
{
"@id": "/api/events/1",
"eventName": "Event 1",
"eventDescription": "Some event 1",
"startDate": "2017-04-19",
"endDate": "2017-04-19"
{
"@id": "/api/events/1",
"eventName": "Event 1",
"eventDescription": "Some event 1",
"startDate": "2017-04-19",
"endDate": "2017-04-19"
}
]
],
"view": [{
"@type": "PartialCollectionView",
"next": "/api/events?page=2",
"first": "/api/events",
"last": "/api/events?page=2"
}]
}
```

Expand All @@ -82,24 +85,26 @@ HTTP 200 OK
{
"@context": "/api/context.jsonld",
"@id": "/api/events?page=2",
"@type": "PartialCollection",
"@type": "Collection",
"manages": {
"property": "rdf:type",
"object": "schema:Event"
},
"previous": "/api/events",
"first": "/api/events",
"last": "/api/events?page=2",
"totalItems": 1,
"member": [
{
"@id": "/api/events/1",
"eventName": "Event 1",
"eventDescription": "Some event 1",
"startDate": "2017-04-19",
"endDate": "2017-04-19"
}
]
{
"@id": "/api/events/1",
"eventName": "Event 1",
"eventDescription": "Some event 1",
"startDate": "2017-04-19",
"endDate": "2017-04-19"
}
],
"view": [{
"first": "/api/events",
"previous": "/api/events",
"last": "/api/events?page=2"
}]
}
```

Expand All @@ -110,4 +115,4 @@ It may be useful to introduce a way to instruct the Hydra client to do so, i.e.:

```javascript
let data = client.get("/api/events", { followPartialLinks: true });
```
```