# How to deal best with relationship in contained list item

**URL:** <https://discuss.jsonapi.org/t/how-to-deal-best-with-relationship-in-contained-list-item/1259>\
**Category:** Uncategorized\
**Created:** [April 9, 2018, 4:37pm UTC](https://discuss.jsonapi.org/t/how-to-deal-best-with-relationship-in-contained-list-item/1259 "2018-04-09T16:37:23Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![marceloverdijk](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.jsonapi.org/marceloverdijk/32/521_2.png) [@marceloverdijk](https://discuss.jsonapi.org/u/marceloverdijk)\
**Post date:** [April 22, 2018, 9:55am UTC](https://discuss.jsonapi.org/t/how-to-deal-best-with-relationship-in-contained-list-item/1259/3 "2018-04-22T09:55:30Z")

</div>

Hi Michael,

It’s quite interesting discussion you linked with various opinions.  
With my case I just wanted represent a simple example as actually my model is a little bit more complicated 😉

That’s why using `"meta"` is not an option.  
So it probably best to introduce a fabricated resource.  
In the example below a use id’s `1, 2` but it probably would be better to use some opaque id here.

Note that I’m also not adding `self` links to the `ingredients` resources as I have no resource endpoint for them.  
Looking at the spec this is not required. So basically this `ingredients` resources can only be retrieved as part of the `recipes` resource, but not on itself, although that feels a little bit weird to be honest.

```
      {
        "data": {
          "type": "recipes",
          "id": "1",
          "attributes": {
            "title": "Baked potatoes",
            "ingredients: [
              { "name": "potatoe", "quantity": "1 kg" },
              { "name": "salt", "quantity": "10 gr" }
            ]
          },
          "ingredients": {
            "links": {
              "self": "http://example.com/recipes/1/relationships/ingredients",
              "related": "http://example.com/recipes/1/ingredients"
            },
            "data": [
              { "type": "ingredients", "id": "1" },
              { "type": "ingredients", "id": "2" }
            ]
          },
          "links": {
            "self": "http://example.com/recipes/1"
          }
        },
        "included": [{
          "type": "ingredients",
          "id": "1",
          "attributes": {
            "name": "potatoe",
            "quantity": "1 kg"
          }
        }, {
          "type": "ingredients",
          "id": "2",
          "attributes": {
            "name": "salt",
            "quantity": "10 gr"
          }
        }]
      }
```

---

_[View the full topic](https://discuss.jsonapi.org/t/how-to-deal-best-with-relationship-in-contained-list-item/1259)._
