JSONAPI-Resources / JSONAPI-Resources/jsonapi-resources
Cross namespace relationships
Nessuno ha ancora preso questa issue.
- Lingua principale
- Ruby
- Stelle
- 2.3k
- Fork
- 546
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
The problem:
Right now namespaces are assumed to be used for versioning, though they could also be used for separating entire sets of resources in isolated namespaces. JR does not currently support resource relationships which cross namespaces. #893 attempts to solve this, but as I brought up in the comments there is the potential for the system to encounter a situation where the correct behavior is ambiguous or will be inconsistent depending on the order of serialization.
Proposal:
A simple set of resource resolution rules could be used to solve this issue without the need to specifically mark up relationships definitions on a resource.
Rules:
- All resource resolution will take place relative to the namespace of the request ("Request Namespace").
- Related resources will be assumed to be in the Request Namespace.
- Resource definitions will support a new method called
global_resourcewhich will register a resource type in a "Global Resource Map" to this resource class. - Declaring two resources classes with the same type as
global_resourcewill raise an exception or emit a warning, which should catch conflicts during development. - If a resource class does not exist in the Request Namespace the Global Resource Map will be consulted for the resource class.
- Resources created from the Global Resource Map will still follow same resolution rules starting with the Request Namespace. In other words relationships in a global resource will first resolve based on the Request Namespace.
I believe these rules should allow unambiguous resolution of resources and prevent runtime issues where a resource is serialized with differing sets of rules (resource definitions), and meet the intent of #893.
Let's discuss this and other proposals here. I haven't tried to code this, but I think it's possible to modify the code to support these rules without a lot of refactoring. If you see potential road blocks in either this project or your projects please raise them here.
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Non vengono indicati file, test o punti di ingresso. Per prima cosa, esamina il comportamento esistente dei namespace e della risoluzione delle relazioni, oltre alla discussione intorno a #893; quindi chiarisci le regole di risoluzione e definisci test che dimostrino un comportamento non ambiguo tra namespace prima dell’implementazione.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- ruby
- Ambito
- api, backend-api-design
- Tipo di issue
- Funzionalità
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Stato di attività
- Ferma
- Chiarezza
- Da chiarire
- Idoneità per principianti
- 25/100