JSONAPI-Resources / JSONAPI-Resources/jsonapi-resources

Nested attributes for relationships

オープン
#424 コメント 3 件 リアクション 3 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

主要言語
Ruby
スター
2.3k
フォーク
546
PR マージ指標
30日以内にマージされた PR はありません

説明

If I were updating / creating a "post" and I also wanted to create / update tag id 3 in the example below, should that be possible (i.e. similar to nested attributes in active record).

Probably a bit of a bad example, but hopefully you get the idea ?

I am finding that each entry in "data" in the relationships must only contain id and type. Nowhere have I yet seen how to do this in json_api in general, not just in this gem so maybe it is not possible. In which case, I guess I would need to create / update the tag seperately, but then I may need to worry about rolling it back if the creation / update of the post did not succeed etc...

post '/posts',
  {
    'posts' => {
      'attributes' => {
        'title' => 'A great new Post'
      },
      'relationships' => {
        'tags' => {
          'data' => [
              {type: 'tags', id: 3, attributes: {name: "New Tag Name"}},
              {type: 'tags', id: 4}
            ]
        }
      }
    }
  }

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

ソースファイル、テスト、エントリーポイントのいずれも指定されていません。まず、既存のリレーションシップの作成・更新処理と、リレーションシップデータに関する JSON:API のルールを確認し、そのうえでネストされた属性がサポートされているかを明らかにしてください。完了条件は、リクエストの動作とトランザクションまたは rollback に関する想定を定義した、明確な判断が得られていることです。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
rails, ruby
領域
api, backend-api-design
issue の種類
機能追加
難易度
5/5
見積もり時間
1週間以上
活発さ
停滞
明瞭さ
説明が足りない
初心者へのやさしさ
25/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。