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
On fetched event hooks for viewing all versions or version diffs #475
Comments
At the very least, the portion of code would have to register the callbacks through a for loop for @jenmontes - want to create a pull request that adds a for loop for |
I actually came to the same conclusion as you and decided to still exclude I'll submit a pull request for this. |
While I was working on this, I think I hit on what may have given you pause before: if HATEOAS is turned on, a normal To illustrate this more plainly, here's a normal {
...
"_links": {
"collection": {
"href": "/posts",
"title": "posts"
},
"parent": {
"href": "/",
"title": "home"
},
"self": {
"href": "/posts/1ouph3",
"title": "post"
}
},
"_version": 2,
"content": {
"text": "OooooOOoooOoh!!"
}
} And here's a {
"_items": [
{
...
"_version": 1,
"content": {
"text": "Hello, world!"
}
},
{
...
"_version": 2,
"content": {
"text": "OooooOOoooOoh!!"
}
}
],
"_links": {
"collection": {
"href": "/posts",
"title": "posts"
},
"parent": {
"href": "/",
"title": "home"
}
}
} So essentially, if HATEOAS is turned on, I'm at a loss for what to do about this. Add |
After looking at the response of {
"_items": [
{
...
"_links": {
"collection": {
"href": "/posts?version=all",
"title": "posts"
},
"parent": {
"href": "/posts",
"title": "home"
},
"self": {
"href": "/posts/1ouph3?version=1",
"title": "post"
}
},
"_version": 1,
"content": {
"text": "Hello, world!"
}
},
{
...
"_links": {
"collection": {
"href": "/posts?version=all",
"title": "posts"
},
"parent": {
"href": "/posts",
"title": "home"
},
"self": {
"href": "/posts/1ouph3?version=2",
"title": "post"
}
},
"_version": 2,
"content": {
"text": "OooooOOoooOoh!!"
}
}
],
"_links": {
"collection": {
"href": "/posts",
"title": "posts"
},
"parent": {
"href": "/",
"title": "home"
},
"self": {
"href": "/posts/1ouph3?version=all",
"title": "post"
}
}
} I'll be the first to admit that it's pretty verbose but the whole point of HATEOAS is to not have to depend on out-of-band knowledge to be able to navigate the API structure. |
Agreed on pretty much all accounts. It seems like your most recent suggestion ( I'm game for really any option here. (Except for adding |
In the end I went for a middle-ground approach where Example: {
"_items": [
{
...
"_links": {
"self": {
"href": "/posts/1ouph3?version=1",
"title": "post"
}
},
"_version": 1,
"content": {
"text": "Hello, world!"
}
},
{
...
"_links": {
"self": {
"href": "/posts/1ouph3?version=2",
"title": "post"
}
},
"_version": 2,
"content": {
"text": "OooooOOoooOoh!!"
}
}
],
"_links": {
"collection": {
"href": "/posts/1ouph3",
"title": "post"
},
"parent": {
"href": "/posts",
"title": "posts"
},
"self": {
"href": "/posts/1ouph3?version=all",
"title": "post"
}
}
} |
This is the same HATEOAS response as on normal collection endpoints, right? So that seems good. 👍 |
There's currently a
TODO
listed in thegetitem
method that is preventing requests with?version=all
or?version=diffs
from executingon_fetched
events. (See here.) The project I'm working on uses event hooks extensively to examine the content of a document before sending it, so I'm particularly interested what needs to be done to get this working.For my project I just commented out the
if
statement that's preventing the event hooks from firing and everything seems to be working fine. What else is missing?/cc @joshvillbrandt because I know document versioning is his baby.
The text was updated successfully, but these errors were encountered: