mattpolzin / mattpolzin/JSONAPI
Redesign Attributes/Relationships around property wrappers
Nobody has claimed this yet.
- Dominant language
- Swift
- Stars
- 81
- Forks
- 21
- PR merge metrics
- No merged PRs in 30d
Description
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]
}
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing the exploration at the linked transformed-property branch and the existing Attribute, TransformedAttribute, and relationship types. Clarify the property-wrapper and relationship design, including chaining or nesting support, before defining completion criteria for the breaking change.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- swift
- Domain
- api
- Issue type
- Refactor
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 15/100