mattpolzin / mattpolzin/JSONAPI

Redesign Attributes/Relationships around property wrappers

未关闭
#38 5 条评论 4 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

enhancement
主要语言
Swift
星标
81
派生
21
PR 合并指标
30 天内没有已合并 PR

描述

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]
}

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

首先查看链接的 transformed-property 分支中的探索内容,以及现有的 Attribute、TransformedAttribute 和 relationship 类型。在定义 breaking change 的完成标准之前,先明确 property-wrapper 和 relationship 的设计,包括对链式调用或嵌套的支持。

由索引模型根据 Issue 内容生成。

评估

技术栈
swift
领域
api
Issue 类型
重构
难度
5/5
预计耗时
一周以上
活跃度
停滞
描述清晰度
需要澄清
新手友好度
15/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。