dsp-api
dsp-api copied to clipboard
Create several values on resource
Is it possible to accept array of values on HTTP POST to http://host/v2/values
end point?
(It is already possible on resource creation endpoint)
{
"@context": {
"rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
"knora-api": "http://api.knora.org/ontology/knora-api/v2#",
"rdfs": "http://www.w3.org/2000/01/rdf-schema#",
"xsd": "http://www.w3.org/2001/XMLSchema#",
"onto": "http://0.0.0.0:3333/ontology/0113/lumieres-lausanne/v2#"
},
"@id": "http://rdfh.ch/0113/XQF3gu-5QkeT4gT73ZD8Cw",
"@type": "onto:Person",
"onto:hasRelationshipValue": [
{
"@type": "knora-api:LinkValue",
"knora-api:linkValueHasTargetIri": {
"@id": "http://rdfh.ch/0113/nVpfhfrXT2C22xc64Zd2xw"
}
},
{
"@type": "knora-api:LinkValue",
"knora-api:linkValueHasTargetIri": {
"@id": "http://rdfh.ch/0113/EXdmJvw4Qbad2ki2J_VN_Q"
}
},
{
"@type": "knora-api:LinkValue",
"knora-api:linkValueHasTargetIri": {
"@id": "http://rdfh.ch/0113/S7oJkpkIR9ijAUa_JQ11jg"
}
}
]
}
This could be implemented but it would require some design changes. Knora has to ensure that cardinalities are respected when values are added, and that the values you add would not duplicate existing values. These checks are simpler when you create a new resource, because we know that there are no previously existing values. This is why the current design allows you to create only one value per request. To make it possible to create multiple values per request, we would need to change the design. I think we can't make it a priority right now, because you can get the same effect by making three requests.
All right, not blocking for me anyway, was just an idea to simplify my client code.
If you try to implement later this issue, you could also think about to try to accept several properties at same time, like to update a resource
. The use case is the UI form with one save button, to avoid multiple http calls and all the related transaction stuffs if one of the property fails.
thx
The use case is the UI form with one save button
I actually think that, from a UX point of view, it's simpler and less confusing for the user to submit one value at a time. Visually, it's easier to pay attention to one thing than several things. If there's an error, there will only be an error for one value, which is visually simpler than dealing with errors for several values at the same time. The old SALSAH GUI only allowed updating one value at a time, and I think that was a good UX design decision.
In theory completely agree with you ! In practice I hope you, as soon as possible, will provide a Typescript lib to deal with the Knora API and all the knora-ui modules to easily build a form to edit values to avoid many cumbersome lines in my app ;-)
In practice I hope you, as soon as possible, will provide a Typescript lib to deal with the Knora API
I'm working on it right now. :)