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
Feature Request: Include Relationship attributes in Entity json output #406
Comments
I like this, and there's already something similar being worked on. Stay tuned. :-) |
excellent -- one request, it would be nice to be able to configure what relationship attributes were included in the output 😄 |
Yes, and there's already existing functionality for nodes (header fields) we can also use for the rel attributes. |
would that require that we use the GET functionality to specify the attributes? Or is it more of a way of indicating which attributes are used via the schema editor (prefer the latter) |
I think it was actually possible to do what you want to achieve for quite some time. You can use the built-in functions
You can even specify the relationship type (see the One of the more recent additions to Structr was a _path property that exposes the last path segment of the path over which the entity was reached. This will only work for nested JSON structures and not for toplevel entities:
Will contain the most recent relationship on the path to the entity you're currently viewing. Does that help? |
I am not sure I understand. How can I use the information about to create a new property on my entity that returns the attribute information for relationships via the REST api? |
In the REST API there's a special view named
Please note that the view will probably be renamed to We're working on a similar view to include relationship information in node queries. |
Sounds good 😄 Question, any chance this attribute that contains the related attributes that is returned on the node query could be used to write updates to back via POST? My thought it that this would help reduce the number of HTTP calls back to the user - so I could update a node and a few of the relationship attributes in a single call, that would be great. |
Any thought on this? Right now, for every entity retrieved I need to make a corresponding HTTP GET request to retrieve the relationship attributes. On mobile and low bandwidth connections (data does still cost money in a LOT of places) this is incredibly expensive :) |
@amorgner I was thinking about this and I don't think the _structr_graph (or _graph) output is going to be very usable. It doesn't line up to any existing entity structure which makes it very difficult to work with in an application. We end up needing to make the query as yet another GET query (structr is getting to be MASSIVELY chatty with all of the GET requests that need to be made), then once we get the results back we need to iterator through them to find the property we need, then extract the value (and possibly due this multiple times), then we would normally put this into an intermediate DTO so that we can work with it within the application. Any thought on going back to the original idea? Provide a way to expose related properties as a "view" in the original GET request (maybe settings header or query param to include/exclude)? |
I would be great if the "public" view of a relationship could be included in the standard entity json results using something like an "attributes" or "_rel" property
Example
or
The text was updated successfully, but these errors were encountered: