JSONAPI-Resources / JSONAPI-Resources/jsonapi-resources

Best practices for making relationships immutable?

Offen
#838 6 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Type: Enhancement
Vorherrschende Sprache
Ruby
Sterne
2.3k
Forks
546
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

From the docs, it looks like we can make a resource read-only by using immutable, but, is there a similar option to restrict operations in a relationship?

Given the following

  # brand has-many motorcycles
  jsonapi_resources :brand 
  jsonapi_resources :motorcycle

I want to restrict the operations between brands/relationships/motorcycles so only GET is allowed.

I found a workaround doing the following, but I wonder if there is a better solution.

jsonapi_resources :brands do
  jsonapi_relationships only: [:get]
end
jsonapi_resources :motorcycles

If that's the case I'll gladly add a note to the README so others can find it too.

Thanks!

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Beginnen Sie mit dem README und der im Issue gezeigten Konfiguration jsonapi_relationships only: [:get] und vergleichen Sie sie mit der dokumentierten Option immutable. Bestätigen Sie, ob diese Konfiguration die unterstützte Möglichkeit ist, nur GET-Operationen für die Beziehung zuzulassen, und dokumentieren Sie anschließend die Anleitung und das Beispiel im README.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
rails, ruby
Bereich
api, documentation
Issue-Typ
Dokumentation
Schwierigkeit
2/5
Geschätzter Aufwand
1-3 Stunden
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
35/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.