mattpolzin / mattpolzin/JSONAPI

Redesign Attributes/Relationships around property wrappers

Aperta
#38 5 commenti 4 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

enhancement
Lingua principale
Swift
Stelle
81
Fork
21
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

Exploration started here: https://github.com/mattpolzin/JSONAPI/tree/feature/transformed-property

This project is on hold until property wrapper chaining (or nesting) is supported (likely Swift 5.2).

The idea I am pursuing is to replace Attribute/TransformedAttribute with an @Attribute attribute and use an @Omittable attribute to represent when attributes can be omitted (i.e. the key is not required). I am a little less solid on relationships, but they would get similar treatment. Then, I additionally would like to flatten things so that attributes and relationships are defined in the same structure with their property attributes being the thing that differentiates them. Definitely have not worked out all of the details yet, but I hope that in addition to being a breaking change this will bring some concision and reduce the overall number of types needed a bit.

Something like

PersonProperties {
  // takes the place of current `Attribute`
  @Attribute
  var name: String

  // where age is stored as a `String` for some reason but we expect it to always be an `Int`
  // takes the place of current `TransformedAttribute`
  @Attribute(deserialize: StringToInt.self)
  var age: Int

  // takes the place of current `ToOneRelationship`
  @Relationship(to: City?.self)
  var hometown: Id?

  // takes the place of current `ToManyRelationship`
  @Relationship(to: [Person].self)
  var friends: [Id]
}

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia esaminando l’esplorazione nel branch transformed-property collegato e i tipi esistenti Attribute, TransformedAttribute e relationship. Chiarisci il design del property-wrapper e delle relazioni, incluso il supporto per il concatenamento o l’annidamento, prima di definire i criteri di completamento della breaking change.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
swift
Ambito
api
Tipo di issue
Refactoring
Difficoltà
5/5
Tempo stimato
Più di una settimana
Stato di attività
Ferma
Chiarezza
Da chiarire
Idoneità per principianti
15/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.