JSONAPI-Resources / JSONAPI-Resources/jsonapi-resources

Default fields resource option

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

还没有人认领这个 Issue。

Type: Enhancement
主要语言
Ruby
星标
2.3k
派生
546
PR 合并指标
30 天内没有已合并 PR

描述

Add an option to the resource class to specify the default fields. Would be used by the request parser if the fields are not specified. Would allow a pared down fields set as the default, while still allowing the full field set if requested.

For example:

class CommentResource < JSONAPI::Resource
  attributes :body
  has_one :post
  has_one :author, class_name: 'Person'
  has_many :tags

  filters :body

  default_fields [:body, :post, :author]
end

Would skip the tags relationship, unless specified in the request.

Comments?

贡献指南

这个仓库没有索引到贡献指南

从这里开始

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

调研方向

首先定位资源类选项处理以及 issue 中提到的请求解析器。跟踪请求的字段和关系是如何被选择的,然后确定默认列表应如何仅在字段缺失时应用。完成的标准是资源可以声明默认字段,被省略的关系默认排除,并且显式请求的字段仍然有效。

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

评估

技术栈
rails, ruby
领域
api, backend
Issue 类型
功能
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 发到你的邮箱

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