JSONAPI-Resources / JSONAPI-Resources/jsonapi-resources

Dynamic relationships

Ouverte
#701 5 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Personne n'a encore pris cette issue.

Type: Enhancement
Langage dominant
Ruby
Étoiles
2.3k
Forks
546
Métriques de merge des PR
Aucune PR mergée en 30 j

Description

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.

Guide de contribution

Aucun guide de contribution indexé pour ce dépôt

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Piste de recherche

Examinez la discussion précédente et les APIs de relations entre ressources, en vous concentrant sur la méthode de classe ou le bloc proposé ainsi que sur l’exemple d’image piloté par les métadonnées. Définissez les critères d’acceptation pour exposer dynamiquement une relation qui peut être incluse ou liée, tout en continuant à prendre en charge les liens fournis par l’application ; l’issue ne nomme aucun fichier ni test, vous devez donc localiser ces points d’entrée avant l’implémentation.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
rails, ruby
Domaine
api, backend
Type d'issue
Fonctionnalité
Difficulté
5/5
Temps estimé
Plus d'une semaine
Activité
À l'abandon
Clarté
À clarifier
Accessibilité débutants
20/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.