Re: [Specifications] Using collection to create resources vs adding members (#237)

This is a design question and itself it probably does not have one answer.

With human audience in mind I would probably go for a diff-like payload, which would simply list members to add and members to remove. The exact specifics are irrelevant as long as the server provides a precise description of such a payload and it is enough for a (human) client to figure out.

The request could be a `PATCH` with changes described using the [Changeset vocabulary](https://vocab.org/changeset)

```turtle
prefix change: <http://purl.org/vocab/changeset/schema#>

# remove /member/1
# add    /member/2
[
  change:removal [
    rdf:subject </collection> ;
    rdf:predicate hydra:member ;
    rdf:object </member/1> ;
  ] ;
  change:addition [
    rdf:subject </collection> ;
    rdf:predicate hydra:member ;
    rdf:object </member/2> ;
  ] 
]
```

The downside is that each collection would need a specific `expects`, for example done with SHACL

```
<> a sh:NodeShape ;
  sh:property [
    sh:name "Remove collection member" ;
    sh:path change:removal ; 
    sh:node [
      sh:property [
        sh:path rdf:subject ;
        sh:hasValue </collection> ;
        dash:hidden true ;
        sh:minCount 1 ;
        sh:maxCount 1 ;
      ], [
        sh:path rdf:predicate ;
        sh:hasValue hydra:member ;
        dash:hidden true ;
        sh:minCount 1 ;
        sh:maxCount 1 ;
      ], [
        sh:path rdf:object ;
      ]
    ]
  ] , 
  sh:property [
    sh:name "Add collection member" ;
    sh:path change:addition ; 
    sh:node [
      sh:property [
        sh:path rdf:subject ;
        sh:hasValue </collection> ;
        dash:hidden true ;
        sh:minCount 1 ;
        sh:maxCount 1 ;
      ], [
        sh:path rdf:predicate ;
        sh:hasValue hydra:member ;
        dash:hidden true ;
        sh:minCount 1 ;
        sh:maxCount 1 ;
      ], [
        sh:path rdf:object ;
      ]
    ]
  ] ;
```

With the `rdf:subject` and `rdf:object` pinned to specific values, hidden, and restricted to exactly one value, all the UI would need is to provide UI for selecting members to add/remove (`rdf:object`)

-- 
GitHub Notification of comment by tpluscode
Please view or discuss this issue at https://github.com/HydraCG/Specifications/issues/237#issuecomment-848548946 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Wednesday, 26 May 2021 07:48:49 UTC