JSONAPI-Resources / JSONAPI-Resources/jsonapi-resources

Dynamic relationships

Offen
#701 5 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

I am using JR for my project finally. I have a requirement which has been talked about before, which I intend to implement myself, but would like to know if this project is interested in receiving it too. If so, I will develop it on a branch, otherwise I will write a custom extension that will live in my app.

In summary, I require that relationships can also be dynamic rather than hard coded using has_many etc..
The idea being that the client side is helped significantly if we translate something that may end up being either complex to read or maybe would require a number of http requests - into a simple relationship that the client can use easier.

Probably best to use an example

Say we have some metadata in our AR model and that meta data has a definition of "some objects of type 'image' with ids 1,2,3,4,5,6", keyed by the name "my_images". Whilst this could be read by the client, they would then have to make decisions on the type, then go and fetch those images themselves.
We want "my_images" to be a relationship that can be included or linked to as normal (we would have to rely on the application to provide the links though as JR could not possible calculate them itself)

I was thinking of an implementation in the resource as a class method that is passed a block which says "define dynamic relationships" and the block could return maybe an array or relationships to define or something like that - but I haven't thought that much into it yet.

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

Überprüfe die bisherige Diskussion und die APIs für Ressourcenbeziehungen, wobei der Fokus auf der vorgeschlagenen Klassenmethode oder dem Block sowie dem metadatengetriebenen Bildbeispiel liegt. Definiere die Akzeptanzkriterien für das dynamische Offenlegen einer Beziehung, die einbezogen oder verknüpft werden kann, während von der Anwendung bereitgestellte Links weiterhin unterstützt werden; im Issue werden keine Dateien oder Tests genannt, daher müssen diese Einstiegspunkte vor der Implementierung ermittelt werden.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
rails, ruby
Bereich
api, backend
Issue-Typ
Feature
Schwierigkeit
5/5
Geschätzter Aufwand
Über eine Woche
Aktivitätsstatus
Veraltet
Klarheit
Muss geklärt werden
Anfängerfreundlichkeit
20/100

Neue Issues direkt in Ihr Postfach

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